Skip to content

Commit e5e3e07

Browse files
committed
Make pdop and sdop instances native sympy objects
1 parent 409bb90 commit e5e3e07

File tree

4 files changed

+265
-193
lines changed

4 files changed

+265
-193
lines changed

galgebra/_full_set.py

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

0 commit comments

Comments
 (0)