Commit 93db476d authored by Martin Reinecke's avatar Martin Reinecke
Browse files

try to address hashing/equality problems and fix caches

parent 7967f2d5
Pipeline #11789 passed with stage
in 10 minutes and 15 seconds
......@@ -43,7 +43,14 @@ class DomainObject(Versionable, Loggable, object):
def __eq__(self, x):
if isinstance(x, type(self)):
return hash(self) == hash(x)
for key in vars(self).keys():
item1 = vars(self)[key]
if key in self._ignore_for_hash or key == '_ignore_for_hash':
continue
item2 = vars(x)[key]
if item1 != item2:
return False
return True
else:
return False
......
......@@ -223,11 +223,7 @@ class FFTW(Transform):
local_offset_Q, is_local, transform_shape=None,
**kwargs):
# generate a id-tuple which identifies the domain-codomain setting
temp_id = (domain.__hash__() ^
(101 * codomain.__hash__()) ^
(211 * transform_shape.__hash__()) ^
(131 * is_local.__hash__())
)
temp_id = (domain,codomain,transform_shape,is_local)
# generate the plan_and_info object if not already there
if temp_id not in self.info_dict:
......
......@@ -22,8 +22,7 @@ class _TransformationCache(object):
self.cache = {}
def create(self, transformation_class, domain, codomain, module):
key = domain.__hash__() ^ ((codomain.__hash__()/111) ^
(module.__hash__())/179)
key = (domain,codomain,module)
if key not in self.cache:
self.cache[key] = transformation_class(domain, codomain, module)
......
......@@ -25,13 +25,13 @@ class _PowerIndexFactory(object):
def get_power_index(self, domain, distribution_strategy,
log=False, nbin=None, binbounds=None):
current_hash = domain.__hash__() ^ (111*hash(distribution_strategy))
key=(domain,distribution_strategy)
if current_hash not in self.power_indices_storage:
self.power_indices_storage[current_hash] = \
if key not in self.power_indices_storage:
self.power_indices_storage[key] = \
PowerIndices(domain, distribution_strategy,
log=log, nbin=nbin, binbounds=binbounds)
power_indices = self.power_indices_storage[current_hash]
power_indices = self.power_indices_storage[key]
power_index = power_indices.get_index_dict(log=log,
nbin=nbin,
binbounds=binbounds)
......
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