Skip to content

Commit 4e57be7

Browse files
author
Tony S Yu
committed
fix uncertainty division bug and add test
1 parent 6e2cea1 commit 4e57be7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

quantities/tests/test_60_uncertainty.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@ def test_uncertainquantity_divide():
8181
str(a/2),
8282
'[ 0.5 1. ] m\n±[ 0.05 0.1 ] m (1σ)'
8383
)
84+
assert_equal(
85+
str(1/a),
86+
'[ 1. 0.5] 1/m\n±[ 0.1 0.05] 1/m (1σ)'
87+
)

quantities/uncertainquantity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def __truediv__(self, other):
148148
def __rtruediv__(self, other):
149149
temp = UncertainQuantity(
150150
1/self.magnitude, self.dimensionality**-1,
151-
1/self.uncertainty.magnitude, copy=False
151+
self.relative_uncertainty/self.magnitude, copy=False
152152
)
153153
return other * temp
154154

0 commit comments

Comments
 (0)