Skip to content

Commit

Permalink
bool
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderthclark committed Sep 22, 2024
1 parent e3a948d commit 69b4826
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,5 @@ freeride/__pycache__/base.cpython-311.pyc
*.pyc
*.pyc
*.pyc
*.pyc
*.pyc
Binary file modified freeride/__pycache__/base.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions freeride/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def __call__(self, x):
else:
raise ValueError(f"{self.x}={x} is outside of the function domain, {self._domain}.")

def __bool__(self):
return not self.is_undefined

def set_symbols(self, symbols):
self.symbols = symbols
if isinstance(symbols, str):
Expand Down
3 changes: 3 additions & 0 deletions freeride/curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ def __init__(self, intercept=None, slope=None, elements=None, inverse=True):
self.intercept = intercept
self.slope = slope

def __bool__(self):
return bool(np.any([bool(el) for el in self.elements]))

@classmethod
def from_two_points(cls, x1, y1, x2, y2):
"""
Expand Down

0 comments on commit 69b4826

Please sign in to comment.