Skip to content

Make unit converters also handle instances of subclasses. #13536

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 1 commit into from
Jun 11, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 27, 2019

PR Summary

Closes #11275.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@dopplershift
Copy link
Contributor

Would it be better to make the cache subclass dict and encapsulate the behavior there?

@anntzer
Copy link
Contributor Author

anntzer commented Mar 2, 2019

It already subclasses dict and the "dict" interface is used for registering converters, which does not go through this logic; so keeping the entire get_converter logic in a separate method looks better to me.

@mhvk
Copy link
Contributor

mhvk commented Jun 10, 2019

Just ran into this bug in astropy and have created astropy/astropy#8818 to work around it by registering all subclasses of our Quantity class. It would be nice to have this fix instead. Beyond the rebase, is there something that can be done to help get it in?

@anntzer
Copy link
Contributor Author

anntzer commented Jun 11, 2019

rebased

@dstansby dstansby added this to the v3.2.0 milestone Jun 11, 2019
@dstansby dstansby merged commit 8e57e5d into matplotlib:master Jun 11, 2019
@anntzer anntzer deleted the unit-subclasses branch June 11, 2019 11:29
@anntzer anntzer mentioned this pull request Jan 13, 2020
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A "TypeError" is raised if subclass inherited from "datetime" is used
5 participants