Replace deprecated tic/toc timers with qe.Timer in kesten_processes - #330
Conversation
✅ Deploy Preview for incomparable-parfait-2417f8 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| a, b, e = jax.tree.map(jnp.exp, (a, b, e)) | ||
| # Update the cross-section of firms | ||
| s = jnp.where(s < s_bar, e, a * s + b) | ||
| s = jnp.where(s < s_bar, e_t, a_t * s + b_t) |
There was a problem hiding this comment.
@devthedevil I don't think this is correct unless we update variables elsewhere. Please review
The timer swap accidentally changed the first generate_cross_section_lax's inner update to reference e_t/a_t/b_t, which are undefined in that function (it binds a, b, e via jax.tree.map). This caused a NameError at execution. Restore the correct e, a, b variables. The second function's e_t/a_t/b_t usage is legitimate and left unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks @devthedevil! I pushed a small maintainer fix (c7310da) alongside the timer swap. The diff had also changed one line in the first - s = jnp.where(s < s_bar, e_t, a_t * s + b_t)
+ s = jnp.where(s < s_bar, e, a * s + b)In that first version, the inner Otherwise the tic/toc → |
Summary
Closes #329.
quanteconis deprecating the Matlab-liketic/tac/toctimers in favour of theTimercontext manager (QuantEcon/QuantEcon.py#833).lectures/kesten_processes.mdwas the only lecture in this repo still using the old API.Change
from quantecon import tic, tocimport (the lecture already doesimport quantecon as qe).tic()/toc()pairs wrapping a single timed call with the equivalentwith qe.Timer():context manager, e.g.:This is a purely mechanical, behavior-preserving swap —
qe.Timer()prints elapsed time on exit by default, matchingtoc()'s existing behavior.Testing
This is a documentation/lecture source file (no associated unit tests). Verified by inspecting the
quantecon.util.timing.Timercontext-manager implementation upstream to confirmwith qe.Timer():is a drop-in replacement for thetic()/toc()pair used here.