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

randbool!(a::Array) is no more implemented #8377

Closed
rfourquet opened this issue Sep 16, 2014 · 8 comments
Closed

randbool!(a::Array) is no more implemented #8377

rfourquet opened this issue Sep 16, 2014 · 8 comments
Labels
domain:randomness Random number generation and the Random stdlib

Comments

@rfourquet
Copy link
Member

This method was deleted in commit 550c57c, but the docs were not updated.
Could a rand(::Type{Bool}) method be added instead?

@JeffBezanson
Copy link
Sponsor Member

Maybe we should deprecate randbool[!] entirely since it is redundant with rand(Bool).

@rfourquet
Copy link
Member Author

I propose that randbool() produces a zero-dimensional array, as now rand(Bool) is the normal way to get a random Bool and the only purpose of randbool is to make BitArrays. I don't know how much randbool(dims) is used, but it could also be deprecated in favor of rand!(Bool, BitArray(dims)).

@rfourquet
Copy link
Member Author

My mistake, the alternative to randbool(dims) is rand!(BitArray(dims)), which makes the point of deprecating randbool stronger (which arguably could be renamed randbit, or the other way: BitArray -> BoolArray).
I can implement that.

@carlobaldassi
Copy link
Member

I don't know how much randbool(dims) is used

I don't know about the general user base, but I use it all the time! (Really, probably some 90% of my projects use it.) So I'll cast a vote to keep it.

I think it also goes together with trues() and falses(), i.e. specialized constructors for commonly needed arrays of Bools.

About renaming BitArray -> BoolArray: that was considered and rejected when BitArrays were originally introduced.

@rfourquet
Copy link
Member Author

@carlobaldassi ok! and what do you think of randbool() returning a zero-dimensional array? (like randbool(()); i.e. in every other cases, randbool(dims...) is similar to randbool(dims)).

@carlobaldassi
Copy link
Member

@rfourquet That seems ok to me, as it makes things more consistent and there's now a perfectly good alternative. But since it's quite breaking, and the new meaning does not seem to be actually very useful in itself, I'd advocate a deprecation period.

@JeffBezanson
Copy link
Sponsor Member

I don't see any value in making randbool() return a 0-d array. Why would you want a 0-d array? We do have ndims(true)==0 and size(true)==(), so I don't think you lose much by getting a scalar.

@rfourquet
Copy link
Member Author

For consistency and because I don't see the need to have this special case, but as you point many array methods apply to scalars, so the status quo is probably ok.

@ViralBShah ViralBShah added the domain:randomness Random number generation and the Random stdlib label Nov 22, 2014
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
Projects
None yet
Development

No branches or pull requests

4 participants