Skip to content

Commit 250deaa

Browse files
kdsudacKenadia
authored andcommitted
adding __eq__ and __str__ to Dimension to make unit testing easier (#713)
* adding __eq__ and __str__ to newly minted Dimension to make unit testing easier * making changes suggested in code review
1 parent 567afe0 commit 250deaa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

openhtf/core/measurements.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,15 @@ def __init__(self, description='', unit=units.NO_DIMENSION):
348348
self.description = description
349349
self.unit = unit
350350

351+
def __eq__(self, other):
352+
return (self.description == other.description and self.unit == other.unit)
353+
354+
def __ne__(self, other):
355+
return not self == other
356+
357+
def __repr__(self):
358+
return '<%s: %s>' % (type(self).__name__, self._asdict())
359+
351360
@classmethod
352361
def from_unit_descriptor(cls, unit_desc):
353362
return cls(unit=unit_desc)

0 commit comments

Comments
 (0)