-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: GH17525 Function _get_standard_colors resets global random seed #17730
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
Merged
jorisvandenbossche
merged 14 commits into
pandas-dev:master
from
cmazzullo:style-random-seed
Oct 3, 2017
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3f0db16
BUG: GH17525 Removed the random seed reset in _style.py
cmazzullo 6ec894b
Added bug documentation to doc/source/whatsnew/v0.21.0.txt
cmazzullo f38bf55
BUG: GH17525 Change function _get_standard_colors to avoid resetting …
cmazzullo 831f70f
Flake8 formatting compliance
cmazzullo 3bf3c0e
Added docstring to internal `random_color` function
cmazzullo 2f3da72
BUG: GH17525 Added test to check for random seed reset
cmazzullo bf9678b
Fixed whitespace for PEP8
cmazzullo f711dd1
Used pandas.core.common._random_state to avoid resetting the seed
cmazzullo 92dbac3
Changed whatsnew to reference the user-visible issue
cmazzullo 4041102
Add tolist() to _get_standard_colors to return the correct type
cmazzullo 6e4e3e5
Changed whatsnew to be clearer
cmazzullo e4f1b0e
Set the random seed in `random_color` to ensure consistent colors are…
cmazzullo 54b2138
Removed `range` import
cmazzullo 092c2d5
change test comment
jorisvandenbossche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,3 +284,20 @@ def test_subplot_titles(self): | |
title=title[:-1]) | ||
title_list = [ax.get_title() for sublist in plot for ax in sublist] | ||
assert title_list == title[:3] + [''] | ||
|
||
def test_get_standard_colors_random_seed(self): | ||
""" For #17525 """ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally, we just add a comment above, not a docstring. |
||
df = DataFrame(np.zeros((10, 10))) | ||
|
||
# Make sure that the random seed isn't reset by _get_standard_colors | ||
plotting.parallel_coordinates(df, 0) | ||
rand1 = random.random() | ||
plotting.parallel_coordinates(df, 0) | ||
rand2 = random.random() | ||
assert rand1 != rand2 | ||
|
||
# Make sure it produces the same colors every time it's called | ||
from pandas.plotting._style import _get_standard_colors | ||
color1 = _get_standard_colors(1, color_type='random') | ||
color2 = _get_standard_colors(1, color_type='random') | ||
assert color1 == color2 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't think
random
provides a context manger, maybe do this like: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.
actually just use this