Skip to content

added alias to gray and grey match same colormaps #26003

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
merged 4 commits into from
Jun 1, 2023

Conversation

madeira-dev
Copy link
Contributor

PR summary

Closes #8965

As suggested in the issue discussion, added alias to match the different spellings of gray and grey in the end of _gen_cmap_registry function in cm.py

cmap_d['grey'] = cmap_d['gist_grey'] = cmap_d['gray']
cmap_d['Grays'] = cmap_d['Greys']
cmap_d['gist_yerg'] = cmap_d['gist_yarg'] = cmap_d['gray_r']
cmap_d['grey_r'] = cmap_d['gray_r']

PR checklist

Copy link

@github-actions github-actions bot 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 for opening your first PR into Matplotlib!

If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@melissawm
Copy link
Member

Welcome, @madeira-dev ! I believe the CI failures are unrelated here.

@madeira-dev
Copy link
Contributor Author

Hi @melissawm!
Thanks for the feedback. Would you also know to tell me if this fix I proposed is the expected one?

@@ -46,6 +46,13 @@ def _gen_cmap_registry():
for cmap in list(cmap_d.values()):
rmap = cmap.reversed()
cmap_d[rmap.name] = rmap

# Register colormap aliases for gray and grey.
cmap_d['grey'] = cmap_d['gist_grey'] = cmap_d['gray']
Copy link
Member

Choose a reason for hiding this comment

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

Let's not make assumptions on equivalence and instead plainliy assign by the naming alias.

Suggested change
cmap_d['grey'] = cmap_d['gist_grey'] = cmap_d['gray']
cmap_d['grey'] = cmap_d['gray']
cmap_d['gist_grey'] = cmap_d['gist_gray']

Please also move this section to before "Generate reversed cmaps" so that you do not need to handle the *_r cases yourself.

@madeira-dev madeira-dev marked this pull request as draft May 31, 2023 16:14
@oscargus
Copy link
Member

Can you please revert the changes of ' to "? And the additional empty lines. Probably your editor did this.

Will be much easier to review the actual changes plus that we prefer to avoid superfluous changes like this.


# Register colormap aliases for gray and grey.
cmap_d["grey"] = cmap_d["gray"]
cmap_d["Greys"] = cmap_d["Grays"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cmap_d["Greys"] = cmap_d["Grays"]
cmap_d["Grays"] = cmap_d["Greys"]

This one, (confusingly, which is what this PR is addressing) is actually defined with an "e" already, so the "a" alias needs to be made, unlike the others.

This is causing import errors (and thus other CI errors)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh okay, I will invert this aliasing and also fix the problems @oscargus mentioned above (it surely happened due to my editor and I just didn't noticed)

@madeira-dev madeira-dev marked this pull request as ready for review May 31, 2023 19:22

# Register colormap aliases for gray and grey.
cmap_d["grey"] = cmap_d["gray"]
cmap_d["gist_grey"] = cmap_d["gist_gray"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cmap_d["gist_grey"] = cmap_d["gist_gray"]
cmap_d["gist_grey"] = cmap_d["gist_gray"]
cmap_d['gist_yerg'] = cmap_d['gist_yarg']

Let's take this as well - It's less likely that somebody will use the other spelling in the reverse spelling, but it does not hurt to have this as well?

Comment on lines 155 to 159
# Someone may set the extremes of a builtin colormap and want to register it
# with a different name for future lookups. The object would still have the
# builtin name, so we should update it to the registered name
if self._cmaps[name].name != name:
self._cmaps[name].name = name
Copy link
Member

Choose a reason for hiding this comment

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

Where does this come from? It seems unrelated to the topic of the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add the alias for the reverse spelling.
Sorry about this unrelated modification, I didn't notice it and can't see where it came from, I'll remove it.

Copy link
Member

@ksunden ksunden left a comment

Choose a reason for hiding this comment

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

Thanks, @madeira-dev, hope to hear from you again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Add alias for colormaps for grey vs gray English issues
6 participants