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

more tweaks

parent 7c4c2af0
Pipeline #31776 failed with stages
in 55 seconds
...@@ -68,8 +68,6 @@ class DomainTuple(object): ...@@ -68,8 +68,6 @@ class DomainTuple(object):
""" """
if isinstance(domain, DomainTuple): if isinstance(domain, DomainTuple):
return domain return domain
if isinstance(domain, dict):
return domain
domain = DomainTuple._parse_domain(domain) domain = DomainTuple._parse_domain(domain)
obj = DomainTuple._tupleCache.get(domain) obj = DomainTuple._tupleCache.get(domain)
if obj is not None: if obj is not None:
...@@ -126,7 +124,8 @@ class DomainTuple(object): ...@@ -126,7 +124,8 @@ class DomainTuple(object):
return self._dom.__hash__() return self._dom.__hash__()
def __eq__(self, x): def __eq__(self, x):
if not isinstance(x, DomainTuple): if self is x:
return True
x = DomainTuple.make(x) x = DomainTuple.make(x)
return self is x return self is x
...@@ -140,9 +139,10 @@ class DomainTuple(object): ...@@ -140,9 +139,10 @@ class DomainTuple(object):
return self.__eq__(x) return self.__eq__(x)
def unitedWith(self, x): def unitedWith(self, x):
if not isinstance(x, DomainTuple): if self is x:
return self
x = DomainTuple.make(x) x = DomainTuple.make(x)
if self != x: if self is not x:
raise ValueError("domain mismatch") raise ValueError("domain mismatch")
return self return self
......
...@@ -75,7 +75,8 @@ class MultiDomain(frozendict): ...@@ -75,7 +75,8 @@ class MultiDomain(frozendict):
return obj return obj
def __eq__(self, x): def __eq__(self, x):
if not isinstance(x, MultiDomain): if self is x:
return True
x = MultiDomain.make(x) x = MultiDomain.make(x)
return self is x return self is x
...@@ -86,20 +87,22 @@ class MultiDomain(frozendict): ...@@ -86,20 +87,22 @@ class MultiDomain(frozendict):
return super(MultiDomain, self).__hash__() return super(MultiDomain, self).__hash__()
def compatibleTo(self, x): def compatibleTo(self, x):
if not isinstance(x, MultiDomain): if self is x:
return True
x = MultiDomain.make(x) x = MultiDomain.make(x)
if (self, x) in MultiDomain._compatCache: if (self, x) in MultiDomain._compatCache:
return True return True
commonKeys = set(self.keys()) & set(x.keys()) commonKeys = set(self.keys()) & set(x.keys())
for key in commonKeys: for key in commonKeys:
if self[key] != x[key]: if self[key] is not x[key]:
return False return False
MultiDomain._compatCache.add((self, x)) MultiDomain._compatCache.add((self, x))
MultiDomain._compatCache.add((x, self)) MultiDomain._compatCache.add((x, self))
return True return True
def subsetOf(self, x): def subsetOf(self, x):
if not isinstance(x, MultiDomain): if self is x:
return True
x = MultiDomain.make(x) x = MultiDomain.make(x)
if (self, x) in MultiDomain._subsetCache: if (self, x) in MultiDomain._subsetCache:
return True return True
...@@ -109,15 +112,16 @@ class MultiDomain(frozendict): ...@@ -109,15 +112,16 @@ class MultiDomain(frozendict):
for key in self.keys(): for key in self.keys():
if key not in x: if key not in x:
return False return False
if self[key] != x[key]: if self[key] is not x[key]:
return False return False
MultiDomain._subsetCache.add((self, x)) MultiDomain._subsetCache.add((self, x))
return True return True
def unitedWith(self, x): def unitedWith(self, x):
if not isinstance(x, MultiDomain): if self is x:
return self
x = MultiDomain.make(x) x = MultiDomain.make(x)
if self == x: if self is x:
return self return self
if not self.compatibleTo(x): if not self.compatibleTo(x):
raise ValueError("domain mismatch") 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