Skip to content

Commit

Permalink
Add comparison methods for Model
Browse files Browse the repository at this point in the history
  • Loading branch information
laffra committed Nov 27, 2024
1 parent f5241d1 commit 7ee8799
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./tests",
"-p",
"test*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
9 changes: 9 additions & 0 deletions ltk/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,15 @@ def __round__(self ): return round(self.value) # pylint: di
def __trunc__(self): return math.trunc(self.value) # pylint: disable=multiple-statements
def __floor__(self): return math.floor(self.value) # pylint: disable=multiple-statements
def __ceil__(self): return math.ceil(self.value) # pylint: disable=multiple-statements

def __eq__(self, value): return self.value == value # pylint: disable=multiple-statements
def __ne__(self, value): return self.value != value # pylint: disable=multiple-statements
def __hash__(self): return hash(self.value) # pylint: disable=multiple-statements

def __lt__(self, value): return self.value < value # pylint: disable=multiple-statements
def __gt__(self, value): return self.value > value # pylint: disable=multiple-statements
def __le__(self, value): return self.value <= value # pylint: disable=multiple-statements
def __ge__(self, value): return self.value >= value # pylint: disable=multiple-statements

def __repr__(self):
return f'"{self.value}"' if isinstance(self.value, str) else repr(self.value)
Expand Down

0 comments on commit 7ee8799

Please sign in to comment.