Skip to content

Conversation

kp992
Copy link
Contributor

@kp992 kp992 commented Aug 15, 2025

Updates the lecture with:

  • Removed pyro and torch code
  • Uses only numpyro backed by JAX.
  • Typos and Code styling.

Fixes #524

@kp992 kp992 requested a review from mmcky August 15, 2025 00:58
@jstac
Copy link
Contributor

jstac commented Aug 15, 2025

Thanks @kp992 !

Copy link

github-actions bot commented Aug 15, 2025

@github-actions github-actions bot temporarily deployed to pull request August 15, 2025 01:40 Inactive
@github-actions github-actions bot temporarily deployed to pull request August 15, 2025 01:41 Inactive
@jstac
Copy link
Contributor

jstac commented Aug 15, 2025

@mmcky : one for the warning checker: /home/runner/miniconda3/envs/quantecon/lib/python3.12/site-packages/IPython/core/pylabtools.py:170: UserWarning: Creating legend with loc="best" can be slow with large amounts of data. fig.canvas.print_figure(bytes_io, **kw)

@jstac
Copy link
Contributor

jstac commented Aug 15, 2025

@kp992 Great job, much appreciated. Are you willing to hand over to some junior RAs to finish the PR?

Perhaps they can compare the code to the style guide and PEP8, plus add some discussion of the figures at the end. (CC @xuanguang-li @matheusvillasb )

@kp992
Copy link
Contributor Author

kp992 commented Aug 15, 2025

Are you willing to hand over to some junior RAs to finish the PR?

I would quickly send a commit to fix doc reference and then we could hand over for adding more notes.

Perhaps they can compare the code to the style guide and PEP8

I have ran the pep8 and style fixes. One easy way to fix that I use is https://pypi.org/project/jupyter-black/.

import jupyter_black
jupyter_black.load()

And Run All Cells to fix the styling.

@kp992
Copy link
Contributor Author

kp992 commented Aug 15, 2025

Thanks for the review @jstac and @mmcky.

Please feel to merge the PR and happy to hand over this lecture for adding more discussions and notes.

@github-actions github-actions bot temporarily deployed to pull request August 15, 2025 04:44 Inactive
@github-actions github-actions bot temporarily deployed to pull request August 15, 2025 04:45 Inactive
@jstac
Copy link
Contributor

jstac commented Aug 15, 2025

@kp992 thanks again.

@matheusvillasb @xuanguang-li are you willing to take over? Perhaps @mmcky can coordinate merge and opening of a new issue.

@xuanguang-li
Copy link
Contributor

Of course @jstac. I will assign myself to the new issue related to this.

@jstac
Copy link
Contributor

jstac commented Aug 15, 2025

Thanks @xuanguang-li !

- Adopt QuantEcon naming format
- Adopt one-line docstring format in accordance with PEP 8
- Change integral notation from $\int dx\, f(x)$ to $\int f(x)\, dx$
- Reorder the illustration of (`param`, `name_dist`) pairs
@github-actions github-actions bot temporarily deployed to pull request August 18, 2025 09:04 Inactive
@github-actions github-actions bot temporarily deployed to pull request August 18, 2025 09:04 Inactive
Copy link

netlify bot commented Sep 9, 2025

Deploy Preview for sunny-cactus-210e3e ready!

Name Link
🔨 Latest commit 4521a7f
🔍 Latest deploy log https://app.netlify.com/projects/sunny-cactus-210e3e/deploys/68c230728a439c00081f71f0
😎 Deploy Preview https://deploy-preview-545--sunny-cactus-210e3e.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.

Copy link

github-actions bot commented Sep 9, 2025

@github-actions github-actions bot temporarily deployed to pull request September 9, 2025 04:14 Inactive
@jstac
Copy link
Contributor

jstac commented Sep 9, 2025

Thanks all!

  • Is there a good reason we are violating pep8 in ShiftedVonMises etc.?
  • Z ~ Normal(a, b) should be Z ~ N(a, b) as in the rest of the lectures
  • rng_key = random.PRNGKey(0) -- don't use magic numbers. Instead the factory function should have a seed argument that defaults to 0.
  • Some lines of code are more than 80 characters.

@xuanguang-li
Copy link
Contributor

Thanks, @jstac, for pointing out these issues.

Is there a good reason we are violating pep8 in ShiftedVonMises etc.?

I think these names follow the convention used in numpyro.distributions, where distributions are written in CapWords form, such as GaussianRandomWalk and HalfCauchy.

https://num.pyro.ai/en/stable/distributions.html

@jstac
Copy link
Contributor

jstac commented Sep 9, 2025

Thanks, @jstac, for pointing out these issues.

Is there a good reason we are violating pep8 in ShiftedVonMises etc.?

I think these names follow the convention used in numpyro.distributions, where distributions are written in CapWords form, such as GaussianRandomWalk and HalfCauchy.

https://num.pyro.ai/en/stable/distributions.html

I see, thanks Kenko :-)

Those are classes, so camel case is appropriate. We are writing functions, so let's swap camel case for lower case with underscores to be consistent with pep8. Please change to shifted_von_mises etc.

Copy link

@github-actions github-actions bot temporarily deployed to pull request September 10, 2025 09:45 Inactive
@xuanguang-li
Copy link
Contributor

Thanks, @jstac.

I’ve implemented your suggestions. In addition, I renamed other functions to lowercase (e.g., MCMC_plotmcmc_plot) to keep the styling consistent.

@jstac
Copy link
Contributor

jstac commented Sep 10, 2025

Thanks @xuanguang-li ! Nice work. The lecture looks great now.

Last request: Can we please use commas to save some lines in

from numpyro.infer import MCMC
from numpyro.infer import NUTS
from numpyro.infer import SVI
from numpyro.infer import Trace_ELBO

After that I'm happy for this to be merged @mmcky

@mmcky
Copy link
Contributor

mmcky commented Sep 11, 2025

Thanks @kp992 and @xuanguang-li for your work on this PR.

Thanks @HumphreyYang and @jstac for your reviews and feedback.

@mmcky mmcky added ready and removed review labels Sep 11, 2025

This comment was marked as outdated.

This comment was marked as outdated.

@mmcky
Copy link
Contributor

mmcky commented Sep 11, 2025

Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-545--sunny-cactus-210e3e.netlify.app (4521a7f)

📚 Changed Lecture Pages: bayes_nonconj

@mmcky
Copy link
Contributor

mmcky commented Sep 11, 2025

The preview mechanism is now showing the latest updates. @jstac I have migrated those imports to the same line as a comma separated list. (will add a note to the style guide as well).

LGTM.

@mmcky
Copy link
Contributor

mmcky commented Sep 11, 2025

thanks @kp992 and @xuanguang-li we are getting some large improvements in runtime for this lecture

(LHS = this PR, RHS = live site)
Screenshot 2025-09-11 at 1 33 11 pm

@mmcky
Copy link
Contributor

mmcky commented Sep 11, 2025

@HumphreyYang merging this PR.

@mmcky mmcky merged commit a7648c0 into main Sep 11, 2025
5 checks passed
@mmcky mmcky deleted the i-524 branch September 11, 2025 03:38
@github-project-automation github-project-automation bot moved this from In Progress to Done in Review Lectures & Modernise Code Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

[bayes_nonconj] Update lecture
5 participants