Skip to content

Commit 013e079

Browse files
committed
Make pdop and sdop instances native sympy objects
1 parent f30de30 commit 013e079

4 files changed

Lines changed: 209 additions & 188 deletions

File tree

galgebra/_full_set.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import collections.abc
2+
3+
4+
class FullSet(set):
5+
""" A set that contains everything. This is used to trick sympy. """
6+
def __contains__(self, x):
7+
return True
8+
9+
def __iter__(self):
10+
raise RuntimeError("Set is infinite")
11+
12+
def __len__(self):
13+
raise RuntimeError("Set is infinite")
14+
15+
def __and__(self, other):
16+
if isinstance(other, set):
17+
return other
18+
return NotImplemented
19+
__rand__ = __and__
20+
21+
def __or__(self, other):
22+
if isinstance(other, set):
23+
return self
24+
return NotImplemented
25+
__ror__ = __or__
26+
27+
def __gt__(self, other):
28+
if isinstance(other, set):
29+
return True
30+
elif isinstance(other, _FullSet):
31+
return False
32+
return NotImplemented
33+
34+
def __lt__(self, other):
35+
if isinstance(other, _FullSet):
36+
return False
37+
return NotImplemented
38+
39+
def __ge__(self, other):
40+
return not (self < other)
41+
42+
def __le__(self, other):
43+
return not (self > other)
44+
45+
def __eq__(self, other):
46+
if isinstance(other, set):
47+
return False
48+
elif isinstance(other, _FullSet):
49+
return True
50+
return NotImplemented
51+
52+
def __bool__(self):
53+
return True

0 commit comments

Comments
 (0)