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 RangeGeneratorInt rename #440

Closed
wants to merge 2 commits into from
Closed

Conversation

malmaud
Copy link
Contributor

@malmaud malmaud commented Dec 29, 2017

No description provided.

@malmaud
Copy link
Contributor Author

malmaud commented Jan 2, 2018

Good to merge?

@ararslan
Copy link
Member

ararslan commented Jan 3, 2018

Needs an entry in the README

src/Compat.jl Outdated

# Cope with renaming of RangeGeneratorInt to SamplerRangeInt
@static if !isdefined(Base.Random, :SamplerRangeInt)
SamplerRangeInt = Base.Random.RangeGeneratorInt
Copy link
Member

Choose a reason for hiding this comment

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

Don't you want a const here?

@@ -1063,6 +1063,8 @@ end
@test Compat.notnothing(1) == 1
@test_throws ArgumentError Compat.notnothing(nothing)

@test isa(Base.Random.RangeGenerator(1:3), Compat.Random.SamplerRangeInt)
Copy link
Member

Choose a reason for hiding this comment

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

Base.Random.RangeGenerator has been kept as an alias for compatibility, but eventually it will go; but I guess this test is fine for now. Also, Random will move to stdlib.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think the test should reference the obsolete name. Maybe

@test extrema([rand(Compat.Random.SamplerRangeInt(1:3)) for i=1:1000]) == (1,3)

@rfourquet
Copy link
Member

This change looks good, do you have a link to an example where it would be used? It's possible that for MersenneTwister, you would get generally better efficiency with using SamplerRangeFast (I'm considering making this the default always in Base). Also, as this PR is to support a newly introduced name, I wonder if this is this best stategy, as depending on the RNG and the number of times you want to generate a random number, the Random.Sampler constructor would choose between SamplerRangeInt and SamplerRangeFast. Cf also JuliaStats/Distributions.jl#697.

@malmaud
Copy link
Contributor Author

malmaud commented Jan 4, 2018

This was designed for https://github.com/JuliaStats/Distributions.jl/pull/700/files. Happy to implement or defer to your implementation of a better approach; I just wanted to get Distributions.jl working again.

@rfourquet
Copy link
Member

I think we can go with your solution for now, and see if a better solution exists when things have stabilized after 1.0 is out.

@quinnj
Copy link
Member

quinnj commented Jan 21, 2018

needs a rebase

@tlnagy
Copy link

tlnagy commented Feb 13, 2018

Any update on this?

@martinholters
Copy link
Member

Updated on top of #601. The test of course fails on Julia past 0.7 as Base.Random is gone, so needs updating. Also, on 0.7 it fails because RangeGenerator there gives a SamplerRangeFast instead of a SamplerRangeInt.

@martinholters
Copy link
Member

Closing as outdated since we've dropped support for Julia prior to 1.0.

@giordano giordano deleted the jmm/rangegenerator branch January 20, 2024 10:00
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.

7 participants