Skip to content

Commit

Permalink
Make pdop and sdop instances native sympy objects
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser committed Apr 22, 2020
1 parent 409bb90 commit 950fd69
Show file tree
Hide file tree
Showing 4 changed files with 273 additions and 198 deletions.
50 changes: 50 additions & 0 deletions galgebra/_full_set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
class FullSet(set):
""" A set that contains everything. This is used to trick sympy. """
def __contains__(self, x):
return True

def __iter__(self):
raise RuntimeError("Set is infinite")

def __len__(self):
raise RuntimeError("Set is infinite")

def __and__(self, other):
if isinstance(other, set):
return other
return NotImplemented
__rand__ = __and__

def __or__(self, other):
if isinstance(other, set):
return self
return NotImplemented
__ror__ = __or__

def __gt__(self, other):
if isinstance(other, set):
return True
elif isinstance(other, FullSet):
return False
return NotImplemented

def __lt__(self, other):
if isinstance(other, FullSet):
return False
return NotImplemented

def __ge__(self, other):
return not (self < other)

def __le__(self, other):
return not (self > other)

def __eq__(self, other):
if isinstance(other, set):
return False
elif isinstance(other, FullSet):
return True
return NotImplemented

def __bool__(self):
return True
Loading

0 comments on commit 950fd69

Please sign in to comment.