-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
API: optimize.quadratic_assignment
: transition to rng (SPEC 7)
#21848
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll work on that PR to allow additional information at the end of the rng
description.
|
Oh, I didn't notice before that Or I can, if you'd prefer. |
Oh. And as you say, it's not even an argument; it's a key in a dictionary. Yeah, this would all have to be custom. Another option is to just not change this function. It is not tightly connected with anything else and probably not super widely used, so I would be content just leaving it alone. |
I'll change the code to start emitting Warnings as per the SPEC-007 (rng is now available for all releases). The SPEC doesn't cover the case if I propose:
|
Yup, that sounds about right! |
A, | ||
B, | ||
method=self.method, | ||
options={"rng": np.random.default_rng(123), "maximize": True} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these needed a specific number for the seed.
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
The failing tests are interesting. They're all from If there is a global seed set, then this will cause complications as tests that just use |
I've had a quick search of the codebase. A global random seed is set in scipy/conftest.py. I think this is presumably set for (doc)testing purposes? Perhaps there are other instances used elsewhere that are propagated into individual tests? |
There is certainly an overabundance of setting |
Alternatively it might be that examining |
I'm not sure about that part. Maybe we can unset it in relevant files? Or we just can't test that particular behavior in CI. |
Indeed it is. This is historic, cf https://github.com/scipy/scipy/blob/main/scipy/conftest.py#L427. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks close - just a few comments (that I'm willing to implement if you're not interested but will allow me to) and fixing the warning in the doc example.
with assert_warns(FutureWarning): | ||
res = quadratic_assignment(A, B, method=self.method, | ||
options={"rng": 0, "maximize": False}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we match
the message and add a test for the other FutureWarning and the DeprecationWarning?
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
Feel free to push to the branch with the changes you'd like to see. |
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
I've made the changes and have added extra tests to check that the warnings are emitted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will commit and merge if tests are happy.
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
…ocs only [docs only]
optimize.quadratic_assignment
: transition to rng (SPEC 7)
No description provided.