Skip to content

Replace deprecated tic/toc timers with qe.Timer in kesten_processes#330

Open
devthedevil wants to merge 1 commit into
QuantEcon:mainfrom
devthedevil:fix/kesten-processes-qe-timer
Open

Replace deprecated tic/toc timers with qe.Timer in kesten_processes#330
devthedevil wants to merge 1 commit into
QuantEcon:mainfrom
devthedevil:fix/kesten-processes-qe-timer

Conversation

@devthedevil

Copy link
Copy Markdown

Summary

Closes #329.

quantecon is deprecating the Matlab-like tic/tac/toc timers in favour of the Timer context manager (QuantEcon/QuantEcon.py#833). lectures/kesten_processes.md was the only lecture in this repo still using the old API.

Change

  • Dropped the now-unused from quantecon import tic, toc import (the lecture already does import quantecon as qe).
  • Replaced all six tic() / toc() pairs wrapping a single timed call with the equivalent with qe.Timer(): context manager, e.g.:
# before
tic()
data = generate_cross_section(firm).block_until_ready()
toc()

# after
with qe.Timer():
    data = generate_cross_section(firm).block_until_ready()

This is a purely mechanical, behavior-preserving swap — qe.Timer() prints elapsed time on exit by default, matching toc()'s existing behavior.

Testing

This is a documentation/lecture source file (no associated unit tests). Verified by inspecting the quantecon.util.timing.Timer context-manager implementation upstream to confirm with qe.Timer(): is a drop-in replacement for the tic()/toc() pair used here.

@netlify

netlify Bot commented Jul 7, 2026

Copy link
Copy Markdown

Deploy Preview for incomparable-parfait-2417f8 ready!

Name Link
🔨 Latest commit 292a208
🔍 Latest deploy log https://app.netlify.com/projects/incomparable-parfait-2417f8/deploys/6a4c9158b299250008f04e24
😎 Deploy Preview https://deploy-preview-330--incomparable-parfait-2417f8.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devthedevil I don't think this is correct unless we update variables elsewhere. Please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace deprecated tic/toc timers with qe.Timer in kesten_processes

2 participants