QuantEcon / QuantEcon/lecture-python.myst
Revert `import jax.random as jr` in jv and career to spelled-out `jax.random`
Nobody has claimed this yet.
- Dominant language
- TeX
- Stars
- 123
- Forks
- 57
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 11
Description
PRs #984 (jv) and #985 (career) both introduced
import jax.random as jr
and use jr.* throughout. These should be reverted to the spelled-out jax.random.* form.
Why
The manual specifies the spelled-out form. manual/styleguide/jax.md (Randomness section) gives:
key = jax.random.key(1234)
shocks = jax.random.normal(key, (100,))
with no alias. The jr alias was in the manual at one point and was deliberately removed in QuantEcon.manual#76, "Refactor JAX random example".
The alias is nonstandard. np and jnp are community conventions a reader arrives already knowing. jr is not — it is local to these two files. A reader who meets jr.split several hundred lines below the import has to scroll back to the top of the lecture to work out what it means. Our lectures are read linearly and often in fragments, so an alias that only pays off for the author is a net cost to the reader.
Affected call sites
lectures/jv.md — import at line 48, uses at 210, 485, 490.
lectures/career.md — import at line 60, uses at 399, 409, 415, 423, 427, 491, 503, 508, 519.
These are the only two files in the repo using the alias.
Related
QuantEcon/action-style-guide rule qe-jax-006 still shows import jax.random as jr together with jr.PRNGKey(42) as its recommended example. That is stale relative to the manual on two counts: the alias, and PRNGKey, which the manual now tells us to replace with jax.random.key. Worth fixing at the source so the checker stops recommending it in other lecture repos.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the imports and listed call sites in lectures/jv.md and lectures/career.md. Replace the local jax.random alias usage with the spelled-out form, then search the repository to confirm these are the only affected lecture files and review the examples against manual/styleguide/jax.md. Done means neither lecture uses the jr alias and the documented style is followed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100