do not allow adding values with different bath numbers

This commit is contained in:
Valentin Boettcher 2022-11-29 18:11:07 -05:00
parent e2f1c76090
commit f8b554fcfe
No known key found for this signature in database
GPG key ID: E034E12B7AF56ACE

View file

@ -189,10 +189,15 @@ class EnsembleValue:
def __add__(
self, other: Union["EnsembleValue", float, int, np.ndarray]
) -> EnsembleValue:
if type(self) == type(other):
if isinstance(other, EnsembleValue):
if len(self) != len(other):
raise RuntimeError("Can only add values of equal length.")
if self.num_baths != other.num_baths:
raise RuntimeError(
"Can only add values pertaining to an equal number of baths."
)
left = self._value
right = other._value