Skip to content

Commit

Permalink
[transform] Add __eq__ / __ne__ to DecomposedTransform
Browse files Browse the repository at this point in the history
  • Loading branch information
behdad committed Dec 15, 2023
1 parent 2621486 commit fb660e6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Lib/fontTools/misc/transform.py
Expand Up @@ -423,6 +423,26 @@ class DecomposedTransform:
tCenterX: float = 0
tCenterY: float = 0

def __eq__(self, other):
if not isinstance(other, DecomposedTransform):
return NotImplemented

Check warning on line 428 in Lib/fontTools/misc/transform.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/misc/transform.py#L428

Added line #L428 was not covered by tests
return (
self.translateX == other.translateX
and self.translateY == other.translateY
and self.rotation == other.rotation
and self.scaleX == other.scaleX
and self.scaleY == other.scaleY
and self.skewX == other.skewX
and self.skewY == other.skewY
and self.tCenterX == other.tCenterX
and self.tCenterY == other.tCenterY
)

def __ne__(self, other):
if not isinstance(other, DecomposedTransform):
return NotImplemented
return not self == other

Check warning on line 444 in Lib/fontTools/misc/transform.py

View check run for this annotation

Codecov / codecov/patch

Lib/fontTools/misc/transform.py#L443-L444

Added lines #L443 - L444 were not covered by tests

@classmethod
def fromTransform(self, transform):
# Adapted from an answer on
Expand Down

0 comments on commit fb660e6

Please sign in to comment.