• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

QuantEcon / QuantEcon.py / 31912350770
91%

Build:
DEFAULT BRANCH: main
Ran 15 Aug 2026 10:36PM UTC
Jobs 1
Files 94
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

15 Aug 2026 10:31PM UTC coverage: 90.605% (+0.04%) from 90.57%
31912350770

push

github

web-flow
ENH: Extend random.draw to accept a random number generator (#917)

* ENH: Extend random.draw to accept a random number generator

`draw` was the only function in `quantecon.random` with no
`random_state` argument. It called `np.random.random()` directly in
both the pure Python body and the `@overload` implementation, so the
generator it used depended on the call site and `np.random.seed` at
Python level had no effect on the jitted path.

Add `random_state` as a trailing keyword argument, matching the name
already used by `probvec`, `sample_without_replacement` and
`DiscreteRV.draw`. The pure Python body routes through
`check_random_state`, so it accepts None, an int seed, a RandomState or
a Generator. The overload takes a narrower contract -- None or a live
`np.random.Generator` -- because nopython mode can neither construct a
generator from a seed nor represent a RandomState; anything else raises
a TypingError at compile time with a message saying what to pass
instead.

A Generator reproduces the host stream bit for bit in nopython mode and
its state is mutated in place, so one generator stays in sync across
Python and jitted calls. That is now the recommended way to get
reproducible draws from a call site that may be jit-compiled.

The change is purely additive. `check_random_state(None)` returns
`np.random.mtrand._rand` by identity and is non-consuming, so the
Python None path is byte-identical to the previous behaviour, and the
jitted None path still uses Numba's internal state, leaving jitted
callers that seed with `np.random.seed` unaffected.

The jitted sized branch keeps its hand-written searchsorted loop rather
than mirroring the Python body's vectorised call: the two agree exactly
but the loop measures about 2x faster at size >= 1000, so
`test_python_jitted_agree` is what holds the paths together instead.

Also raise the numba floor to 0.59.0. The overload needs
`types.NumPyRandomGeneratorType`, added in numba 0.56.0, and 0.59.0 is
the firs... (continued)

35 of 35 new or added lines in 1 file covered. (100.0%)

5140 of 5673 relevant lines covered (90.6%)

0.91 hits per line

Jobs
ID Job ID Ran Files Coverage
1 31912350770.1 15 Aug 2026 10:36PM UTC 94
90.6
GitHub Action Run
Source Files on build 31912350770
  • Tree
  • List 94
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #31912350770
  • ae4df0f4 on github
  • Prev Build on main (#31871479665)
  • Next Build on main (#31922203706)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc