python-quantities-developers team mailing list archive
-
python-quantities-developers team
-
Mailing list archive
-
Message #00120
[Bug 311698] Re: trying to change units to incompatible units alters some units
** Changed in: python-quantities
Status: Fix Committed => Fix Released
--
trying to change units to incompatible units alters some units
https://bugs.launchpad.net/bugs/311698
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:
>>> from quantities import *
from
>>> from numpy import *
>>> J
Quantity(1.0), kg * m^2 / s^2 #this is correct!
>>> x = 100 *s
>>> x.units = inch * J #now try changing units to something wrong
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
x.units = inch * J
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/quantities-1.0-py2.5-macosx-10.3-i386.egg/quantities/quantity.py", line 81, in _set_units
self._units.set_units(units)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/quantities-1.0-py2.5-macosx-10.3-i386.egg/quantities/dimensionality.py", line 101, in set_units
raise IncompatibleUnits('convert between', self._udunits(), units._udunits())
IncompatibleUnits: Cannot convert between quanitites with units of 's' and 'kg in^3 s^-2'
>>> J
Quantity(1550.0031000061997), kg * m^2 / s^2 # totally wrong! somehow this operation has changed J