# return false if the polyhedron is empty, true otherwise
raise not self.isempty()
+ def _symbolunion(self, *others):
+ symbols = set(self.symbols())
+ for other in others:
+ symbols.update(other.symbols())
+ return sorted(symbols)
+
def __eq__(self, other):
- symbols = set(self.symbols()) | set(other.symbols())
+ symbols = self._symbolunion(other)
string = '{} = {}'.format(self._toiscc(symbols), other._toiscc(symbols))
string = _iscc.eval(string)
return string == 'True'
return (self & other).isempty()
def issubset(self, other):
- symbols = set(self.symbols()) | set(other.symbols())
+ symbols = self._symbolunion(other)
string = '{} <= {}'.format(self._toiscc(symbols), other._toiscc(symbols))
string = _iscc.eval(string)
return string == 'True'
return self.issubset(other)
def __lt__(self, other):
- symbols = set(self.symbols()) | set(other.symbols())
+ symbols = self._symbolunion(other)
string = '{} < {}'.format(self._toiscc(symbols), other._toiscc(symbols))
string = _iscc.eval(string)
return string == 'True'
def issuperset(self, other):
# test whether every element in other is in the polyhedron
- symbols = set(self.symbols()) | set(other.symbols())
+ symbols = self._symbolunion(other)
string = '{} >= {}'.format(self._toiscc(symbols), other._toiscc(symbols))
string = _iscc.eval(string)
return string == 'True'
return self.issuperset(other)
def __gt__(self, other):
- symbols = set(self.symbols() + other.symbols())
+ symbols = self._symbolunion(other)
string = '{} > {}'.format(self._toiscc(symbols), other._toiscc(symbols))
string = _iscc.eval(string)
return string == 'True'
def union(self, *others):
# return a new polyhedron with elements from the polyhedron and all
# others (convex union)
- symbols = set(self.symbols())
- for other in others:
- symbols.update(other.symbols())
- symbols = sorted(symbols)
+ symbols = self._symbolunion(*others)
strings = [self._toiscc(symbols)]
for other in others:
strings.append(other._toiscc(symbols))
return self.union(other)
def intersection(self, *others):
- symbols = set(self.symbols())
- for other in others:
- symbols.update(other.symbols())
+ symbols = self._symbolunion(*others)
symbols = sorted(symbols)
strings = [self._toiscc(symbols)]
for other in others:
def difference(self, *others):
# return a new polyhedron with elements in the polyhedron that are not
# in the others
- symbols = set(self.symbols())
- for other in others:
- symbols.update(other.symbols())
+ symbols = self._symbolunion(*others)
symbols = sorted(symbols)
strings = [self._toiscc(symbols)]
for other in others: