Commit 120a0998 authored by Martin Reinecke's avatar Martin Reinecke

more tweaks

parent 7c4c2af0
Pipeline #31776 failed with stages
in 55 seconds
......@@ -68,8 +68,6 @@ class DomainTuple(object):
"""
if isinstance(domain, DomainTuple):
return domain
if isinstance(domain, dict):
return domain
domain = DomainTuple._parse_domain(domain)
obj = DomainTuple._tupleCache.get(domain)
if obj is not None:
......@@ -126,8 +124,9 @@ class DomainTuple(object):
return self._dom.__hash__()
def __eq__(self, x):
if not isinstance(x, DomainTuple):
x = DomainTuple.make(x)
if self is x:
return True
x = DomainTuple.make(x)
return self is x
def __ne__(self, x):
......@@ -140,9 +139,10 @@ class DomainTuple(object):
return self.__eq__(x)
def unitedWith(self, x):
if not isinstance(x, DomainTuple):
x = DomainTuple.make(x)
if self != x:
if self is x:
return self
x = DomainTuple.make(x)
if self is not x:
raise ValueError("domain mismatch")
return self
......
......@@ -75,8 +75,9 @@ class MultiDomain(frozendict):
return obj
def __eq__(self, x):
if not isinstance(x, MultiDomain):
x = MultiDomain.make(x)
if self is x:
return True
x = MultiDomain.make(x)
return self is x
def __ne__(self, x):
......@@ -86,21 +87,23 @@ class MultiDomain(frozendict):
return super(MultiDomain, self).__hash__()
def compatibleTo(self, x):
if not isinstance(x, MultiDomain):
x = MultiDomain.make(x)
if self is x:
return True
x = MultiDomain.make(x)
if (self, x) in MultiDomain._compatCache:
return True
commonKeys = set(self.keys()) & set(x.keys())
for key in commonKeys:
if self[key] != x[key]:
if self[key] is not x[key]:
return False
MultiDomain._compatCache.add((self, x))
MultiDomain._compatCache.add((x, self))
return True
def subsetOf(self, x):
if not isinstance(x, MultiDomain):
x = MultiDomain.make(x)
if self is x:
return True
x = MultiDomain.make(x)
if (self, x) in MultiDomain._subsetCache:
return True
if len(x) == 0:
......@@ -109,15 +112,16 @@ class MultiDomain(frozendict):
for key in self.keys():
if key not in x:
return False
if self[key] != x[key]:
if self[key] is not x[key]:
return False
MultiDomain._subsetCache.add((self, x))
return True
def unitedWith(self, x):
if not isinstance(x, MultiDomain):
x = MultiDomain.make(x)
if self == x:
if self is x:
return self
x = MultiDomain.make(x)
if self is x:
return self
if not self.compatibleTo(x):
raise ValueError("domain mismatch")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment