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

Skip to content

Commit 5652163

Browse files
committed
Robustify AffineBase.__eq__ against comparing to other classes.
We already check whether `other` has an is_affine attribute, so we may as well check whether it has a `get_matrix`.
1 parent db55918 commit 5652163

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/matplotlib/transforms.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,8 +1685,7 @@ def set(self, child):
16851685

16861686
class AffineBase(Transform):
16871687
"""
1688-
The base class of all affine transformations of any number of
1689-
dimensions.
1688+
The base class of all affine transformations of any number of dimensions.
16901689
"""
16911690
is_affine = True
16921691

@@ -1699,7 +1698,7 @@ def __array__(self, *args, **kwargs):
16991698
return self.get_matrix()
17001699

17011700
def __eq__(self, other):
1702-
if getattr(other, "is_affine", False):
1701+
if getattr(other, "is_affine", False) and hasattr(other, "get_matrix"):
17031702
return np.all(self.get_matrix() == other.get_matrix())
17041703
return NotImplemented
17051704

0 commit comments

Comments
 (0)