-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Limited available colors #38247
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
Not sure if bug is the good label... |
Two small scripts used for that.
|
def tests_css_named_colors_valid(): | ||
upper_hexs = set(map(str.upper, string.hexdigits)) | ||
for color in CSSToExcelConverter.NAMED_COLORS.values(): | ||
assert len(color) == 6 and all(c in upper_hexs for c in color) |
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.
Would you consider adding a test that all colors from matplotlib.colors.CS4_COLORS
are present in NAMED_COLORS
?
Or would that be an overkill?
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.
Yeah, I wondered a bit about that, but didn't make my mind.
It's not long to write, so I've pushed a commit for that, but no problem for removing it.
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.
-1 on adding a big list like this. let's just use the mpl machinery here (by importing the color defs)
pandas/io/formats/excel.py
Outdated
@@ -65,27 +65,156 @@ class CSSToExcelConverter: | |||
CSS processed by :meth:`__call__`. | |||
""" | |||
|
|||
# source: matplotlib 3.3.3, matplotlib.colors.CSS4_COLORS |
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 just import these?
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.
possible of course, but is it worth introducing a dependency on mpl for excel manipulation?
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.
It sounds reasonable for me to have a list of colors, rather than depend on matplotlib.
Could think of placing the list into a separate module, so that pandas/io/formats/excel.py
is not cluttered?
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 used matplotlib nomenclature (_color_data.py), maybe something else will be more adequate
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.
pls add a whatsnew note, other enhancements for 1.2
@@ -0,0 +1,151 @@ | |||
# source: matplotlib._color_data (3.3.3) |
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 you add some more commentary here, why we need this and we don't want to depend on using mpl for this data.
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.
done
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.
thanks. Do we have any need for this in plotting itself? @ivanovmg @charlesdong1991 @jorisvandenbossche
pandas/io/formats/excel.py
Outdated
@@ -25,6 +25,8 @@ | |||
from pandas.io.formats.format import get_level_lengths | |||
from pandas.io.formats.printing import pprint_thing | |||
|
|||
from ._color_data import CSS4_COLORS |
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.
use a fully qualifed import
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.
done
(removing 1.2 milestone, since this is not critical to include) |
thanks @ma3da |
Co-authored-by: Luis Pinto <[email protected]>
(GH37967)
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff