Skip to content
Snippets Groups Projects
Commit 30087a54 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Add more checks and make it easy to extend to other attribtes

parent ba26a8a7
No related branches found
No related tags found
No related merge requests found
......@@ -74,9 +74,13 @@ class Result(dict):
setattr(self, key, val)
def __add__(self, other):
if other.sampler != self.sampler:
raise ValueError(
"Unable to add results generated from different samplers")
matches = ['sampler', 'search_parameter_keys']
for match in matches:
# The 1 and 0 here ensure that if either doesn't have a match for
# some reason, a error will be thrown.
if getattr(other, match, 1) != getattr(self, match, 0):
raise ValueError(
"Unable to add results generated with different {}".format(match))
self.samples = np.concatenate([self.samples, other.samples])
self.posterior = pd.concat([self.posterior, other.posterior])
......
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