Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions quantities/tests/test_uncertainty.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def test_uncertainquantity_multiply(self):
self.assertQuantityEqual(a*2, [2, 4]*pq.m)
self.assertQuantityEqual((a*2).uncertainty, [0.2,0.4]*pq.m)

def test_uncertainquantity_negative(self):
a = UncertainQuantity([1, 2], 'm', [.1, .2])
self.assertQuantityEqual(-a, [-1., -2.]*pq.m)
self.assertQuantityEqual((-a).uncertainty, [0.1, 0.2]*pq.m)
self.assertQuantityEqual(-a, a*-1)
self.assertQuantityEqual((-a).uncertainty, (a*-1).uncertainty)

def test_uncertainquantity_divide(self):
a = UncertainQuantity([1, 2], 'm', [.1, .2])
self.assertQuantityEqual(a/a, [1., 1.])
Expand Down
3 changes: 3 additions & 0 deletions quantities/uncertainquantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def __mul__(self, other):
def __rmul__(self, other):
return self.__mul__(other)

def __neg__(self):
return self*-1

@with_doc(Quantity.__truediv__, use_header=False)
def __truediv__(self, other):
res = super(UncertainQuantity, self).__truediv__(other)
Expand Down