diff options
| author | Peter LaFosse <peter@vector35.com> | 2021-09-23 10:14:19 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2021-09-23 10:25:41 -0400 |
| commit | 9f3f29a79d08a4d1a5081ffe2bd9d59436a873bf (patch) | |
| tree | f51a4870b1a7e4a6078c4f7adc5cd5c3d1ff9133 /python | |
| parent | b2f9382f0bf3719aa46077454e623ac4bb542020 (diff) | |
Add comparison operators for SizeWithConfidence and OffsetWithConfidence
Diffstat (limited to 'python')
| -rw-r--r-- | python/types.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/python/types.py b/python/types.py index 2a141846..c5ce1924 100644 --- a/python/types.py +++ b/python/types.py @@ -346,6 +346,27 @@ class OffsetWithConfidence: def __int__(self): return self.value + def __eq__(self, other): + if not isinstance(other, self.__class__): + return self.value == int(other) + else: + return (self.value, self.confidence) == (other.value, other.confidence) + + def __ne__(self, other): + return not (self == other) + + def __gt__(self, other): + return self.value > int(other) + + def __le__(self, other): + return self.value <= int(other) + + def __ge__(self, other): + return self.value >= int(other) + + def __lt__(self, other): + return self.value < int(other) + def _to_core_struct(self) -> core.BNOffsetWithConfidence: result = core.BNOffsetWithConfidence() result.value = self.value @@ -419,6 +440,27 @@ class SizeWithConfidence: def __int__(self): return self.value + def __eq__(self, other): + if not isinstance(other, self.__class__): + return self.value == int(other) + else: + return (self.value, self.confidence) == (other.value, other.confidence) + + def __ne__(self, other): + return not (self == other) + + def __gt__(self, other): + return self.value > int(other) + + def __le__(self, other): + return self.value <= int(other) + + def __ge__(self, other): + return self.value >= int(other) + + def __lt__(self, other): + return self.value < int(other) + def _to_core_struct(self) -> core.BNSizeWithConfidence: result = core.BNSizeWithConfidence() result.value = self.value |
