Skip to content

Update rand and nalgebra with opt-in wasm_js support#384

Open
day01 wants to merge 4 commits into
statrs-dev:mainfrom
day01:feature/wasm-js-and-deps-update
Open

Update rand and nalgebra with opt-in wasm_js support#384
day01 wants to merge 4 commits into
statrs-dev:mainfrom
day01:feature/wasm-js-and-deps-update

Conversation

@day01

@day01 day01 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

MOTIVATION

I encountered this while using statrs in a Leptos application targeting
wasm32-unknown-unknown.

Seeded sampling should not require a host entropy source, while browser
applications using APIs such as rand::rng() need an explicit JavaScript
entropy backend.

This PR separates these use cases: the regular rand feature supports seeded
RNGs without enabling host entropy, while the new opt-in wasm_js feature
enables JavaScript-backed randomness.

Changes

  • Update rand from 0.9 to 0.10.
  • Update nalgebra from 0.34 to 0.35 to keep its rand integration compatible.
  • Migrate sampling implementations to the rand 0.10 RngExt API.
  • Use nalgebra/rand-no-std to avoid implicitly enabling thread_rng.
  • Enable rand/std_rng for explicitly seeded RNGs without requiring
    getrandom.
  • Add the opt-in wasm_js feature, enabling:
    • rand/thread_rng
    • getrandom/wasm_js
  • Add CI checks for:
    • wasm32-unknown-unknown with seeded RNG support
    • wasm32-unknown-unknown with wasm_js
    • wasm32-wasip1
  • Update examples, benchmarks, documentation, and the MSRV lockfile.
  • Increase MSRV from 1.87 to 1.89, as required by nalgebra 0.35.

Acknowledgements

Thanks to @RobertJacobsonCDC for the earlier rand 0.9 migration in #331,
@qkniep for the work on the rand 0.10 migration in #374

@day01

day01 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Previously, both benchmarks almost always measured the fast path returning NaN instead of the intended selection algorithms.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.41%. Comparing base (75303bb) to head (7df8f81).

Files with missing lines Patch % Lines
src/generate.rs 0.00% 4 Missing ⚠️
src/distribution/dirichlet.rs 0.00% 1 Missing ⚠️
src/distribution/multivariate_normal.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #384      +/-   ##
==========================================
+ Coverage   94.39%   94.41%   +0.01%     
==========================================
  Files          59       59              
  Lines       12982    12990       +8     
==========================================
+ Hits        12254    12264      +10     
+ Misses        728      726       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@day01

day01 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

I don't think so coverage on display is necessary, but if you req that @YeungOnion i will add...

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.

1 participant