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

Enable AppVeyor, remove randi() #279

Merged
merged 3 commits into from
Jul 2, 2017
Merged

Enable AppVeyor, remove randi() #279

merged 3 commits into from
Jul 2, 2017

Conversation

nalimilan
Copy link
Member

No description provided.

Copy link
Member

@ararslan ararslan left a comment

Choose a reason for hiding this comment

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

sigh Windows, a necessary evil

@nalimilan
Copy link
Member Author

@ararslan I've added a much more invasive commit. You may want to revise your approval...

For future reference, the randi vs rand performance issue is detailed at JuliaLang/julia#22600.

@nalimilan nalimilan changed the title Enable AppVeyor Enable AppVeyor, remove randi() Jun 28, 2017
@ararslan
Copy link
Member

You may want to revise your approval

Nah, this is still fine by me. Any idea whether any packages that depend on StatsBase use that sampler directly?

@nalimilan
Copy link
Member Author

Any idea whether any packages that depend on StatsBase use that sampler directly?

Looking on GitHub, looks like there are a few uses, mostly in old, unmaintained packages. One exception is Distributions. So I've added deprecations which fix the tests for that package until we port it.

The remaining failure on 32-bit 0.6 is unrelated, see JuliaLang/julia#22613.


using Base.Random: RangeGenerator
@deprecate_binding RandIntSampler RangeGenerator
@deprecate RangeGenerator(K::Int) RangeGenerator(1:K)
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused by this. Did you mean for the former to be RandIntSampler?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a tricky situation. I first tried to do @deprecate RandIntSampler(K::Int) RangeGenerator(1:K), but that triggers a deprecation warning when loading StatsBase. So that's the only solution I could find. That's a kind of type piracy, but hopefully we won't have to keep this for too long.

Copy link
Member

Choose a reason for hiding this comment

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

What if you move the binding deprecation to the end?

Copy link
Member Author

Choose a reason for hiding this comment

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

Then I get a constant redefinition error (IIRC)...

Copy link
Member

Choose a reason for hiding this comment

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

Hmmmmmmmmm, maybe

@deprecate (::Type{RandIntSampler})(K::Int) RangeGenerator(1:K)

?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I don't use @deprecate_binding, the depwarn is not triggered, but I need to use const RandIntSampler = RangeGenerator, and then the methods are added to RangeGenerator. So that's equivalent to the current situation of the PR. If I only define RandIntSampler as a function, the places where it's used as a type will break (there's one case in Distributions, see JuliaStats/Distributions.jl#630). We can certainly do that, the question is whether it's better or worse than the type piracy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess another strategy would be to make a temporary type with a silly name like UseRangeGeneratorInstead, I think some of the linspace / float-range deprecations in base were done like 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.

I'm not so concerned about the absence of a deprecation warning: it's unlikely that a package would use the type without any of the associated functions, which do print warnings. But however the type would be named, how would ensure at the same type that the old code continues to work (both code using the type and code using the functions)? AFAICT that requires type piracy.

Copy link
Contributor

Choose a reason for hiding this comment

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

You'd make it an entirely new type, only for the purposes of keeping the deprecated code working. The warnings could say the right thing for the function calls, but the deprecate_binding warnings when it's used in type signatures would have the funny name.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, actually the simplest solution seems to be moving the :RandIntSampler code to deprecates.jl, and printing deprecation warnings from the inner constructors. No type piracy involved. The use of the binding itself does not print a message, but you can't fix the warnings without removing the uses of the type anyway, and the only package which used this unexported type was Distributions. So should be good to go.

…andIntGenerator

This fixes the inconsistency between 32-bit and 64-bit. rand() is somewhat
slower than randi() when getting a single random number, but we should
improve the implementation in Base if needed.

Add deprecations since some packages used these internal methods.
@ararslan
Copy link
Member

ararslan commented Jul 2, 2017

What happened to covm on nightly...?

@nalimilan
Copy link
Member Author

See #281.

@ararslan
Copy link
Member

ararslan commented Jul 2, 2017

Ah that's right, thanks for taking care of that!

@ararslan ararslan merged commit 37f392a into master Jul 2, 2017
@ararslan ararslan deleted the nl/appveyor branch July 2, 2017 20:05
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.

3 participants