Title: Don't fail on equal-but-differently-named cmaps in qt figureoptions. by anntzer · Pull Request #29148 · matplotlib/matplotlib · GitHub
Open Graph Title: Don't fail on equal-but-differently-named cmaps in qt figureoptions. by anntzer · Pull Request #29148 · matplotlib/matplotlib
X Title: Don't fail on equal-but-differently-named cmaps in qt figureoptions. by anntzer · Pull Request #29148 · matplotlib/matplotlib
Description: Currently, opening the Qt figureoptions UI for an image whose cmap is not registered in the colormap registry, has a name not matching any registry entry, but is actually equal (==, i.e. has the same LUT and colorbar-extension attributes) to a registry entry, leads to an error. A typical example would be import cmap, pylab as p # third-party p.imshow([[0, 1]], cmap=cmap.Colormap("bids:magma").to_mpl()) and opening the qt figure options; this leads to the error "index 'bids:magma' is invalid ...". Note that if the cmap is different from any registered cmap then we already add it to the UI combobox (try e.g. cmap=cmap.Colormap("imagej:fire")); the only problem was if it was equal to a registered cmap (this arises because when the code was originally written, cmap instance equality was by identity, not by comparing LUTs, so the cmap not in cm._colormaps.values() check behaved differently). Fix that by checking whether the colormap name is registered. The behavior is still ill-defined in the opposite (theoretical) case of an unregistered cmap different from any registered cmap but with a matching name, but I'd argue that case is more pathological. Test by running the above code and opening the qt figureoptions. (aka how some code I wrote 9 years ago (#5469, a bit scary it's been that long) got broken by some code written 5.5 years later (#20227), and how to fix that with a one-line patch with 20 lines of explanation. I guess that's technically a regression :-)) PR summary PR checklist "closes #0000" is in the body of the PR description to link the related issue new and changed code is tested Plotting related features are demonstrated in an example New Features and API Changes are noted with a directive and release note Documentation complies with general and docstring guidelines
Open Graph Description: Currently, opening the Qt figureoptions UI for an image whose cmap is not registered in the colormap registry, has a name not matching any registry entry, but is actually equal (==, i.e. has the sa...
X Description: Currently, opening the Qt figureoptions UI for an image whose cmap is not registered in the colormap registry, has a name not matching any registry entry, but is actually equal (==, i.e. has the sa...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/29148
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:4a30cb67-4c1a-e6c2-dbe5-8c00ce4ec52f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 99B2:176010:1517EDA:1C86569:6A534E05 |
| html-safe-nonce | 4b872db2a441be9ba0fa5e6ed3e61b4563575d4d7d59b7ade8f02dbf0225573c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OUIyOjE3NjAxMDoxNTE3RURBOjFDODY1Njk6NkE1MzRFMDUiLCJ2aXNpdG9yX2lkIjoiMTk0NTc5NjcyNjA4MjMwOTE3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 35dee630ee4e3e1d11b5cd9e631147529065457753999d40debafd109cd2a594 |
| hovercard-subject-tag | pull_request:2182756189 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/29148/files |
| twitter:image | https://avatars.githubusercontent.com/u/1322974?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1322974?s=400&v=4 |
| og:image:alt | Currently, opening the Qt figureoptions UI for an image whose cmap is not registered in the colormap registry, has a name not matching any registry entry, but is actually equal (==, i.e. has the sa... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width