-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make pdop and sdop instances native sympy objects
- Loading branch information
1 parent
409bb90
commit 950fd69
Showing
4 changed files
with
273 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.