Repository navigation
Honour T and the documented rfn forms in sprand with a value function - #1109
Merged
Merged
Conversation
…method Without an RNG, `sprand` with a value function dropped `T`, so the result took the eltype of `rfn` and `rfn` was called once more to recompute the default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l in sprand Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ViralBShah
force-pushed
the
vs/sprand-rfn-eltype
branch
from
October 26, 2026 13:48
b306f92 to
41c35d7
Compare
T of sprand(m, n, p, rfn, T) on to the RNG methodT and the documented rfn forms in sprand with a value function
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1109 +/- ##
=======================================
Coverage 94.72% 94.73%
=======================================
Files 16 16
Lines 10318 10337 +19
=======================================
+ Hits 9774 9793 +19
Misses 544 544 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sprandwith a value functionrfnmishandlesT. Without an RNG,sprand(m, n, p, rfn, T)ignoresT. WithoutT, it callsrfnextra times just to find the eltype. The vectorsprand([rng], n, p, rfn, T)rejects the documentedrfn(k)andrfn(rng, k): it only accepts an undocumentedrfn(rng, T, k).Before
After
The matrix method without an RNG now passes
Ton. WithoutT, the matrix methods take the eltype from the valuesrfnreturns, instead of a throwaway callrfn(1)that also drew from the RNG. The vector methods withTnow call the documentedrfn(k)orrfn(rng, k)and convert toT, as the matrix methods do. They keep acceptingrfn(rng, T, k), checked withapplicable. The docstring now says whatTafterrfndoes.Changed stream: seeded
sprand([rng], m, n, p, rfn)calls with a customrfnand noTdraw less from the RNG, so their values change. Every other form passesTitself and is unchanged:sprand([rng], [T], m, n, p),sprandnand the vector forms,sprand(Xoshiro(42), 50, 50, 0.3)among them, which is bitwise identical tomain.🤖 Generated with Claude Code