summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Linke <dalito@users.noreply.github.com>2014-06-18 19:35:34 +0200
committerDavid Linke <dalito@users.noreply.github.com>2014-06-18 19:35:34 +0200
commit7aea835a80193bf7ea2d39f8068dffe8330bb06d (patch)
tree28b614e0c5c1ce2a53d4d240529308af41db5cf4
parent70c5b1396ba972a5b3fdef6146c52cae2abf3ece (diff)
downloadpint-7aea835a80193bf7ea2d39f8068dffe8330bb06d.tar.gz
Fixed problem with uncertainties
When adding two measurements the error is different if both measurements are the same versus if they are different. For this testing M1 is M2 must give true. This was not the case because a new object was created for M2 when converting.
-rw-r--r--pint/quantity.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/pint/quantity.py b/pint/quantity.py
index 2e2596e..509c0a3 100644
--- a/pint/quantity.py
+++ b/pint/quantity.py
@@ -318,8 +318,10 @@ class _Quantity(object):
# Presence of non-multiplicative units gives rise to several cases.
if is_self_multiplicative and is_other_multiplicative:
+ if self._units == other._units:
+ self._magnitude = op(self._magnitude, other._magnitude)
# If only self has a delta unit, other determines unit of result.
- if self._get_delta_units() and not other._get_delta_units():
+ elif self._get_delta_units() and not other._get_delta_units():
self._magnitude = op(self._convert_magnitude(other.units),
other._magnitude)
self._units = copy.copy(other.units)
@@ -412,8 +414,11 @@ class _Quantity(object):
# Presence of non-multiplicative units gives rise to several cases.
if is_self_multiplicative and is_other_multiplicative:
+ if self._units == other._units:
+ magnitude = op(self._magnitude, other._magnitude)
+ units = copy.copy(self.units)
# If only self has a delta unit, other determines unit of result.
- if self._get_delta_units() and not other._get_delta_units():
+ elif self._get_delta_units() and not other._get_delta_units():
magnitude = op(self._convert_magnitude(other.units),
other._magnitude)
units = copy.copy(other.units)