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

Potentially ambiguous rand behaviour #33309

Closed
aahaselgrove opened this issue Sep 18, 2019 · 2 comments
Closed

Potentially ambiguous rand behaviour #33309

aahaselgrove opened this issue Sep 18, 2019 · 2 comments
Labels
docs This change adds or pertains to documentation randomness Random number generation and the Random stdlib

Comments

@aahaselgrove
Copy link

I ran into unexpected behaviour today calling the rand function. I expected rand((2,)) to interpret the tuple as dimensions, whereas it actually interpreted it as the set of values from which to be drawing from randomly.

In my opinion, a tuple does not (and should not) represent a 'set of values', but rather be a compound data type where each element has an explicit meaning (such as with dims, where each element of the tuple represents the length of specific dimension), and hence, should not be a valid type for S.

Should this be changed?

@rfourquet
Copy link
Member

It was interpreted as dimensions in the past, and was changed with the new meaning (partily for performance reasons) in Julia 1.1 I think, see #25278.

@rfourquet rfourquet added the randomness Random number generation and the Random stdlib label Sep 18, 2019
@aahaselgrove
Copy link
Author

aahaselgrove commented Sep 18, 2019

Fair enough. Possibly this should be clarified in the documentation to make it obvious, as it was a somewhat annoying bug to find. All I can see currently is "Support for S as a tuple requires at least Julia 1.1."

@rfourquet rfourquet added the docs This change adds or pertains to documentation label Nov 1, 2019
KristofferC pushed a commit that referenced this issue Apr 11, 2020
* docs: disambiguate what rand((2, 3)) does (fix #33309)

* Update stdlib/Random/src/Random.jl

Co-Authored-By: Matt Bauman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation randomness Random number generation and the Random stdlib
Projects
None yet
Development

No branches or pull requests

2 participants