-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
[Bug]: mpl.colormaps[ "Grays" ].name is "Greys", not "Grays" #28114
Comments
It's a bit more involved than just changing the name attribute. There is currently only one underlying
Not sure which approach is better. The first is less complex, but we loose from-code accessible information on aliases (not that we have used that before). So slight tendency to go with the first. We can always build explicit aliases in later if we need to. |
My knee-jerk reaction was "can we just keep living with this", but looking into it a bit, if colormaps are added through The On This also suggests that rather than fixing the name on the way in, we should be fixing the name on the way out (as we have already paid to make a copy). |
This issue inspired me to do #28115 |
That would be still an option.
This was added to prevent users from manipulating the builtin colormaps, e.g. via
I don't follow that argument. The existing copy only means: We can fix the name of the way out without additional cost. I still think it's not the right way, because we have a sketchy internal state. |
I may be missing something, but isn't the idea of an alias that is should return the object that it aliases? Now, it is not so clear which is the original and alias here and maybe they are mixed-up? But the thing that an alias returns a different name than the alias name is expected? |
That depends on the interpertation. First and foremost, we want to give users the convenience that 'grey' and 'gray' are equally possible. AFAIK, we have not publically defined the mechanism how that is implemented. If we publically say "One is canonical and the other is just an alias for accessing I think the second approach is more pragmatic, because Note also that since we currently do copies on |
Thanks @timhoffm. Agree completely, immutability, readonly, is Good. (What surprised me: I was plotting colormaps with ΔE color diffs, about like
|
Bug summary
A minor bug, with a simple fix:
mpl.colormaps[ "Grays" ].name
is "Greys", not "Greys"Code for reproduction
Actual outcome
mpl.colormaps[ "Grays" ].name = 'Greys'
Expected outcome
mpl.colormaps[ "Grays" ].name = 'Grays'
Additional information
A suggested fix: in cm.py, after lines 47 - 50
change their .name s too:
Operating system
macos 10.15.7
Matplotlib Version
3.8.4
Matplotlib Backend
No response
Python version
3.10.0
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered: