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

Skip to content

Commit ff365ec

Browse files
authored
Merge pull request #16893 from anntzer/affineq
Robustify `AffineBase.__eq__` against comparing to other classes.
2 parents ea6b224 + 5652163 commit ff365ec

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
@@ -1611,8 +1611,7 @@ def set(self, child):
16111611

16121612
class AffineBase(Transform):
16131613
"""
1614-
The base class of all affine transformations of any number of
1615-
dimensions.
1614+
The base class of all affine transformations of any number of dimensions.
16161615
"""
16171616
is_affine = True
16181617

@@ -1625,7 +1624,7 @@ def __array__(self, *args, **kwargs):
16251624
return self.get_matrix()
16261625

16271626
def __eq__(self, other):
1628-
if getattr(other, "is_affine", False):
1627+
if getattr(other, "is_affine", False) and hasattr(other, "get_matrix"):
16291628
return np.all(self.get_matrix() == other.get_matrix())
16301629
return NotImplemented
16311630

0 commit comments

Comments
 (0)