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
Pipeline #24228 passed with stages
in 1 minute and 42 seconds
......@@ -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])
......
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