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

Replace the use of randbool() #9569

Merged
merged 1 commit into from
Jan 3, 2015
Merged

Replace the use of randbool() #9569

merged 1 commit into from
Jan 3, 2015

Conversation

ViralBShah
Copy link
Member

Deprecate randbool (#9105).
For a random Bool, instead of randbool(), use rand(Bool)
Instead of randbool(dims), use bitrand(dims)

@ViralBShah
Copy link
Member Author

Cc: @carlobaldassi

As discussed in #9105, I have only addressed randbool here. I will do bittrues and bitfalses in a different PR.

@@ -259,3 +259,5 @@ const base64 = base64encode

@deprecate sizehint(A, n) sizehint!(A, n)

@deprecate randbool() rand(Bool)
@deprecate randbool(x...) bitrand(x)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these different?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because randbool() produces a Bool, whereas bitrand() produces a BitArray (as it should).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the forwarding of randbool taking an AbstractRNG won't work as is, nor randbool((2,3)).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're right, did not realize randbool() with no inputs gave a Bool, nevermind. Glad we're deprecating that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rfourquet Thanks. I have added all the deprecation cases, and they work correctly now.

@deprecate randbool(dims) bitrand(dims)
@deprecate randbool(dims...) bitrand(dims)
@deprecate randbool(r, dims) bitrand(r, dims)
@deprecate randbool(r, dims...) bitrand(r, dims)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

randbool(1, 2, 3) won't work, and randbool(MersenneTwister()) won't work as expected, I think you can't avoid using type annotations here!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep losing track of all the different method signatures!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not have rand(r::AbstractRNG, t::Type) so that different RNGs can be used to generate random values of various integer/boolean types? It appears not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind. We do have it - but I was trying in 0.3.4, which was open in another window.

@ViralBShah
Copy link
Member Author

The linux failure is a segfault, and appears unrelated (but worrisome).

@tkelman
Copy link
Contributor

tkelman commented Jan 3, 2015

The linux failure is a segfault, and appears unrelated (but worrisome).

I used almost the exact same wording in another PR, though when it happened on OSX. Probably related to #9544 #9570, the ccall(:raise) might be getting caught by some signal handler inside the LLVM JIT and breaking things maybe?

@ViralBShah
Copy link
Member Author

Now it happened in OS X here...

For a random Bool, instead of randbool(), use rand(Bool)
Instead of randbool([rng], dims), use bitrand([rng], dims)
Add randbool deprecation to NEWS
ViralBShah pushed a commit that referenced this pull request Jan 3, 2015
Replace the use of randbool()
@ViralBShah ViralBShah merged commit b365c36 into master Jan 3, 2015
@ViralBShah ViralBShah deleted the vs/randbool branch January 3, 2015 13:21
jkbest2 added a commit to jkbest2/Distributions.jl that referenced this pull request May 2, 2016
As per JuliaLang/julia#9569, `randbool()` has been deprecated in favor of `rand(Bool)`.
ararslan pushed a commit to JuliaStats/Distributions.jl that referenced this pull request Jul 19, 2016
As per JuliaLang/julia#9569, `randbool()` has been deprecated in favor of `rand(Bool)`.
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.

None yet

5 participants