Commit c385b8bc authored by Theo Steininger's avatar Theo Steininger
Browse files

Merge branch 'issue77_2' into 'master'

try to address hashing/equality problems and fix caches

See merge request !72
parents 42951308 bd1e0f27
Pipeline #11891 passed with stages
in 16 minutes and 4 seconds
......@@ -40,7 +40,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)
......
......@@ -157,7 +157,6 @@ class Space(DomainObject):
"""
super(Space, self).__init__()
self._ignore_for_hash += ['_global_id']
@abc.abstractproperty
def harmonic(self):
......
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