Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Don't use global np.random.seed in tests #13356

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

praths007
Copy link
Contributor

@praths007 praths007 commented Mar 1, 2019

Reference Issues/PRs

Don't use global np.random.seed in tests #13345

What does this implement/fix? Explain your changes.

Replaced instances in tests and doctests where seed was set globally using np.random.seed with
rng = np.random.RandomState
so that the class variable rng can be used to generate random numbers instead of the global value of seed set using np.random.seed.

Any other comments?

Issue #13345 can be checked for more details

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on. Let's see if tests pass, otherwise looks good.

- passed rng as parameter to ParameterSampler class
- changed seed from 0 to 42 (as original)
- passed rng as parameter to SparseRandomProjection class
- passed rng as parameter to GaussianRandomProjection class
@praths007
Copy link
Contributor Author

@rth - all tests have passed now

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Thank you @praths007 !

@agramfort agramfort merged commit e43574e into scikit-learn:master Mar 2, 2019
@agramfort
Copy link
Member

thx @praths007

@praths007 praths007 deleted the Don't_use_global_np.random.seed_in_tests branch March 2, 2019 08:00
@praths007 praths007 restored the Don't_use_global_np.random.seed_in_tests branch March 4, 2019 09:28
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
* initial commit

* used random class

* fixed failing testcases, reverted __init__.py

* fixed failing testcases #2
- passed rng as parameter to ParameterSampler class
- changed seed from 0 to 42 (as original)

* fixed failing testcases #2
- passed rng as parameter to SparseRandomProjection class

* fixed failing testcases scikit-learn#4
- passed rng as parameter to GaussianRandomProjection class

* fixed failing test case because of flake 8
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
xhluca pushed a commit to xhluca/scikit-learn that referenced this pull request Apr 28, 2019
koenvandevelde pushed a commit to koenvandevelde/scikit-learn that referenced this pull request Jul 12, 2019
* initial commit

* used random class

* fixed failing testcases, reverted __init__.py

* fixed failing testcases scikit-learn#2
- passed rng as parameter to ParameterSampler class
- changed seed from 0 to 42 (as original)

* fixed failing testcases scikit-learn#2
- passed rng as parameter to SparseRandomProjection class

* fixed failing testcases scikit-learn#4
- passed rng as parameter to GaussianRandomProjection class

* fixed failing test case because of flake 8
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