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

Skip to content

Commit 877636d

Browse files
authored
Merge pull request #8399 from anntzer/fix-axesstack-formatting-transforms-eq
Fix % formatting and Transform equality.
2 parents c5c5a5d + f5ad81d commit 877636d

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

lib/matplotlib/figure.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,18 @@ def add(self, key, a):
118118
# All the error checking may be unnecessary; but this method
119119
# is called so seldom that the overhead is negligible.
120120
if not isinstance(a, Axes):
121-
raise ValueError("second argument, %s, is not an Axes" % a)
121+
raise ValueError("second argument, {!r}, is not an Axes".format(a))
122122
try:
123123
hash(key)
124124
except TypeError:
125-
raise ValueError("first argument, %s, is not a valid key" % key)
125+
raise ValueError(
126+
"first argument, {!r}, is not a valid key".format(key))
126127

127128
a_existing = self.get(key)
128129
if a_existing is not None:
129130
Stack.remove(self, (key, a_existing))
130131
warnings.warn(
131-
"key %s already existed; Axes is being replaced" % key)
132+
"key {!r} already existed; Axes is being replaced".format(key))
132133
# I don't think the above should ever happen.
133134

134135
if a in self:

lib/matplotlib/transforms.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,11 +1156,9 @@ def __radd__(self, other):
11561156
raise TypeError(
11571157
"Can not add Transform to object of type '%s'" % type(other))
11581158

1159-
def __eq__(self, other):
1160-
# equality is based on transform object id. Hence:
1161-
# Transform() != Transform().
1162-
# Some classes, such as TransformWrapper & AffineBase, will override.
1163-
return self is other
1159+
# Equality is based on object identity for `Transform`s (so we don't
1160+
# override `__eq__`), but some subclasses, such as TransformWrapper &
1161+
# AffineBase, override this behavior.
11641162

11651163
def _iter_break_from_left_to_right(self):
11661164
"""

0 commit comments

Comments
 (0)