← Back to team overview

python-quantities-developers team mailing list archive

[Bug 386145] Re: units on uncertainty not correctly handled for division (solution attached)

 

** Changed in: python-quantities
       Status: Fix Committed => Fix Released

-- 
units on uncertainty not correctly handled for division (solution attached)
https://bugs.launchpad.net/bugs/386145
You received this bug notification because you are a member of Python
Quantities Development Team, which is subscribed to python-quantities.

Status in Physical Quantities for Python: Fix Released

Bug description:
The units of an uncertainty are not changed by division. This bug can be reproduced as follows

>>> L = pq.UncertainQuantity(1, pq.m, 0.1)
>>> print L / pq.m

In the above the quantity has dimensionless units (as expected), but the uncertainty has dimensions of "m". This error can be fixed with the following patch.

-Tony

PS: I'm running quantities 0.5b3

=== modified file 'quantities/uncertainquantity.py'
--- quantities/uncertainquantity.py	2009-04-01 20:05:00 +0000
+++ quantities/uncertainquantity.py	2009-06-11 22:39:17 +0000
@@ -136,7 +136,7 @@
             ru = (sru**2+oru**2)**0.5
             u = res.view(Quantity) * ru
         except AttributeError:
-            other = np.array(other, copy=False)
+            other = np.array(other, copy=False, subok=True)
             u = (self.uncertainty**2/other**2)**0.5
 
         res._uncertainty = u