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

Remove rand hacks and use make instead #1388

Open
lgoettgens opened this issue Jun 22, 2023 · 8 comments
Open

Remove rand hacks and use make instead #1388

lgoettgens opened this issue Jun 22, 2023 · 8 comments

Comments

@lgoettgens
Copy link
Collaborator

All over AA, there are custom rand methods, that insert the RNG as a first argument, e.g.

As mentioned above, we define a simplified random generator that saves the user
having to create make instances.
```julia
rand(rng::AbstractRNG, S::PolyRing, deg_range::UnitRange{Int}, v...) =
rand(rng, make(S, deg_range, v...))
rand(S::PolyRing, degs, v...) = rand(Random.GLOBAL_RNG, S, degs, v...)
```

In particular, they change rand(make(S, 1:3, -10:10)) to rand(S, 1:3, -10:10).

The RandomExtensions documentation strongly suggests to always use make in calls and not use the hack, see
https://github.com/JuliaRandom/RandomExtensions.jl/blob/f5d9723da41cb85f8c8be6ae21cb220ea3101ccc/README.md?plain=1#L35-L42

Furthermore, according to Aqua.test_ambiguity(AbstractAlgebra), these custom rand methods are part of 587 of the 622 ambiguities total!

Most of these methods have been there for at least 3 years untouched, some even longer (just been moved around between files a few times). And I think due to the above reasons, it is time for some refactoring.

@thofma
Copy link
Member

thofma commented Jun 22, 2023

Will this fix the problem observed in JuliaRandom/RandomExtensions.jl#13?

@lgoettgens
Copy link
Collaborator Author

lgoettgens commented Jun 22, 2023

Will this fix the problem observed in JuliaRandom/RandomExtensions.jl#13?

Yes, exactly that is what I meant. Thanks for pointing to the issue.

@thofma
Copy link
Member

thofma commented Jun 22, 2023

I am also not sure I understand the ramifications. Will we have to use rand(make(S...)) instead of rand(S,...)?

@lgoettgens
Copy link
Collaborator Author

I am also not sure I understand the ramifications. Will we have to use rand(make(S...)) instead of rand(S,...)?

As far as I have understood it (and my testing showed nothing contradicting that), this is the only visible change to the user.

@thofma
Copy link
Member

thofma commented Jun 22, 2023

I think writing rand(make(S,...)) instead of rand(S,...) is not acceptable. Maybe we should just ditch RandomExtensions if it makes loading everything so much slower.

@fieker
Copy link
Contributor

fieker commented Jun 23, 2023

I too think that rand(make(..)) cannot fly. We've only recently looked at the creation of random mpolys and I am afraid a normal user will not be able to create them using the current design> The proposed it worse. It's cool for experts but impossible for users

@fingolfin
Copy link
Member

I also don't like rand(make(...)) and in light of the recent total breakage of RandomExtensions.jl (it doesn't work anymore with latest Julia nightly), I am tempted to agree that we should just ditch it.

See oscar-system/Oscar.jl#2896 for a different proposal.

@lgoettgens lgoettgens changed the title Remove rand hacks to not need make Remove rand hacks and use make instead Jan 17, 2024
@lgoettgens
Copy link
Collaborator Author

Removing these Hacks at a later stage would be a breaking change, so I think we need to address this part before 1.0 (even without a final concept and implementation of oscar-system/Oscar.jl#2896).

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

No branches or pull requests

4 participants