Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support random sampling of tuple types: add tests #51630

Merged
merged 1 commit into from
Oct 7, 2023

Conversation

rfourquet
Copy link
Member

This is a rebase of #35856, where we keep only the tests, as the functionality was added in #50251. This also adds the possibility to call rand on an empty tuple type: rand(Tuple{}).

EDIT: this was also implemented in #50251, which is now merged, so
merge this now for the added tests, and the added feature of
`rand(Tuple{})`.

This allows e.g `rand(NTuple{5,Int})` to sample a tuple of 5 `Int`s.

The implementation simply assembles a tuple by calling `rand` on the
corresponding type parameters of the tuple type.
A generated function is used to ensure type stability.
@rfourquet rfourquet added the domain:randomness Random number generation and the Random stdlib label Oct 7, 2023
@rfourquet rfourquet added the kind:bugfix This change fixes an existing bug label Oct 7, 2023
@rfourquet rfourquet merged commit 3bb0392 into master Oct 7, 2023
8 checks passed
@rfourquet rfourquet deleted the stev47-feature/random-tuple-type branch October 7, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:randomness Random number generation and the Random stdlib kind:bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants