Conversation
|
Many thanks @kp992 . @mmcky or @HumphreyYang , could you please do a first round review of this? The aim is that swapping to NumPy's interp should not change outputs or degrade performance. |
|
Note that this is related to QuantEcon/lecture-python-advanced.myst#156 |
|
@jstac re: performance
Some lectures actually improved and some are a bit slower. I don't see any major timing issues. |
|
Remaining lectures to migrate
@kp992 can you let me know if there is an equivalent to |
|
@kp992 I know it violates our usual practice but let's try and fix them all in one PR -- so they are in one commit. This lecture series is not in high frequency editing at the moment so I am happy with that approach. |
| plt.rcParams["figure.figsize"] = (11, 5) #set default figure size | ||
| from numba import njit, prange, vectorize | ||
| from interpolation import mlinterp, interp | ||
| from interpolation import mlinterp |
There was a problem hiding this comment.
@kp992 is there a corresponding function in numpy for mlinterp?
There was a problem hiding this comment.
No @mmcky, there's not.
There is in SciPy but it's not jit compilable. Let's stick to interpolation for the multivariate case.
There was a problem hiding this comment.
That's right, @jstac. I didn't find mlinterp in numpy too.
There was a problem hiding this comment.
@kp992 we will need interpolation package updated unless mlinterp doesn't use generated_jit. Would you have time to look into that?
| @@ -1,5 +1,4 @@ | |||
| import numpy as np | |||
| from interpolation import interp | |||
There was a problem hiding this comment.
I didn't see pip install interpolation removed from this lecture... was that task forgotten?
There was a problem hiding this comment.
Thanks @jstac. I think we can remove this file completely. This isn't use anywhere in any lectures. In optgrowth, it seems to be have been replace by from scipy.interpolate import interp1d.
% git grep bellman_operator
lectures/_static/lecture_specific/odu/odu.py: def bellman_operator(self, v):
lectures/_static/lecture_specific/wald_friedman/wald_class.py: def bellman_operator(self, J):
lectures/_static/lecture_specific/wald_friedman/wald_class.py: J = qe.compute_fixed_point(self.bellman_operator, np.zeros(self.m),
lectures/_static/lecture_specific/wald_friedman/wf_first_pass.py:def bellman_operator(pgrid, c, f0, f1, L0, L1, J):
lectures/_static/lecture_specific/wald_friedman/wf_first_pass.py:bell_op = lambda vf: bellman_operator(pg, 0.5, f0, f1, 5.0, 5.0, vf)|
thanks @jstac for searching the |
|
@kp992 are you happy for this to be merged? |
This PR replaces
interpolation.interptonp.interpnow thatnumbasupportsnp.interpdirectly. Also, removesplt.rcParams["figure.figsize"] = (11, 5) #set default figure sizeredundant line.