Skip to content

Commit 1269b93

Browse files
authored
MAINT: Use np.interp as supported by numba (#138)
1 parent 287de43 commit 1269b93

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lectures/cake_eating_numerical.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
2525
```{code-cell} ipython3
2626
:tags: [hide-output]
2727
28-
!pip install interpolation quantecon
28+
!pip install quantecon
2929
```
3030

3131
We will use the following imports.
@@ -324,7 +324,6 @@ for the purpose of comparing the results of JAX implementation.
324324
```{code-cell} ipython3
325325
import numpy as np
326326
from numba import prange, njit
327-
from interpolation import interp
328327
from quantecon.optimize import brent_max
329328
```
330329

@@ -360,7 +359,7 @@ def state_action_value_numba(c, x, v_array, cem):
360359
* v_array: value function array guess, 1-D array
361360
* cem: Cake Eating Numba Model instance
362361
"""
363-
return u_numba(c, cem) + cem.β * interp(cem.x_grid, v_array, x - c)
362+
return u_numba(c, cem) + cem.β * np.interp(x - c, cem.x_grid, v_array)
364363
```
365364

366365
```{code-cell} ipython3

lectures/ifp_egm.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ We will use the following libraries and imports.
3333
```{code-cell} ipython3
3434
:tags: [hide-output]
3535
36-
!pip install --upgrade quantecon interpolation
36+
!pip install --upgrade quantecon
3737
```
3838

3939
```{code-cell} ipython3
@@ -43,7 +43,6 @@ import numpy as np
4343
import jax
4444
import jax.numpy as jnp
4545
46-
from interpolation import interp
4746
from numba import njit, float64
4847
from numba.experimental import jitclass
4948
```
@@ -483,7 +482,7 @@ def K_egm_nb(a_in, σ_in, ifp):
483482
484483
# Linear interpolation of policy using endogenous grid
485484
def σ(a, z):
486-
return interp(a_in[:, z], σ_in[:, z], a)
485+
return np.interp(a, a_in[:, z], σ_in[:, z])
487486
488487
# Allocate memory for new consumption array
489488
σ_out = np.zeros_like(σ_in)

0 commit comments

Comments
 (0)