Skip to content
Snippets Groups Projects
Commit d1a295c4 authored by Bruce Edelman's avatar Bruce Edelman
Browse files

changed from repr to tuple to convert list to something that can be used as a...

changed from repr to tuple to convert list to something that can be used as a dict key, and make cached attribute 'protected' with _
parent 5b1a5778
No related branches found
No related tags found
No related merge requests found
Pipeline #112039 failed
......@@ -41,7 +41,7 @@ class PriorDict(dict):
self.from_file(filename)
elif dictionary is not None:
raise ValueError("PriorDict input dictionary not understood")
self.cached_normalizations= {}
self._cached_normalizations= {}
self.convert_floats_to_delta_functions()
......@@ -380,8 +380,8 @@ class PriorDict(dict):
return all_samples
def normalize_constraint_factor(self, keys):
if repr(keys) in self.cached_norm_factors.keys():
return self._cached_normalizations[repr(keys)]
if tuple(keys) in self._cached_normalizations.keys():
return self._cached_normalizations[tuple(keys)]
else:
min_accept = 1000
sampling_chunk = 5000
......@@ -398,7 +398,7 @@ class PriorDict(dict):
[all_samples[key], samples[key].flatten()])
keep = np.array(self.evaluate_constraints(all_samples), dtype=bool)
factor = len(keep) / np.count_nonzero(keep)
self._cached_normalizations[repr(keys)] = factor
self._cached_normalizations[tuple(keys)] = factor
return factor
def prob(self, sample, **kwargs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment