Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix % formatting and Transform equality. #8399

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

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Mar 29, 2017

Use .format(key) instead of % key formatting which fails when key
is a tuple (one could also use % (key,) but we may as well use the
more modern option).

The Transform class doesn't need to override __eq__ as user-defined
classes default to using identity for equality. This also avoids having
to add a __hash__ to these classes to make them hashable (by default,
user-defined classes are hashable, but become unhashable (in Py3) if
they define a __eq__ without defining a __hash__). A more complete
PR should define __hash__ for all Transform subclasses too.


Partial fix for #8395 (a full fix needs to restore hashability of most Transform subclasses).

Use `.format(key)` instead of `% key` formatting which fails when `key`
is a tuple (one could also use `% (key,)` but we may as well use the
more modern option).

The `Transform` class doesn't need to override `__eq__` as user-defined
classes default to using identity for equality.  This also avoids having
to add a `__hash__` to these classes to make them hashable (by default,
user-defined classes are hashable, but become unhashable (in Py3) if
they define a `__eq__` without defining a `__hash__`).  A more complete
PR should define `__hash__` for all `Transform` subclasses too.
Copy link
Member

@phobson phobson left a comment

Choose a reason for hiding this comment

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

LGTM

@phobson phobson modified the milestone: 2.1 (next point release) Mar 31, 2017
@dstansby dstansby merged commit 877636d into matplotlib:master Apr 12, 2017
@anntzer anntzer deleted the fix-axesstack-formatting-transforms-eq branch April 12, 2017 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants