OpenMDAO/OpenMDAO-Framework — Issue #825: Unit parsing fails for prefixed units unless they have been parsed before
Author: ssalonen
Created: 2012-02-05 17:15:58+00:00
State: open

I'm using openmdao-0.2.3.

I get an error when running this:

python -c "from openmdao.units import PhysicalQuantity as pq;pq(1, 'g/kW')"

Traceback:

Traceback (most recent call last):
File "", line 1, in
File "C:\src\openmdao-0.2.3\lib\site-packages\openmdao.units-0.2.3-py2.7.egg\openmdao\units\units.py", line 118, in __init__
self.unit = _find_unit(args[1])
File "C:\src\openmdao-0.2.3\lib\site-packages\openmdao.units-0.2.3-py2.7.egg\openmdao\units\units.py", line 577, in _find_unit
raise ValueError, "no unit named '%s' is defined" % item
ValueError: no unit named 'g/kW' is defined

But **no** error when running this:

python -c "from openmdao.units import PhysicalQuantity as pq;pq(1, 'kW');pq(1, 'g/kW')"

To me it seems like that openmdao.units cannot parse complex units if
1) they include prefixed units (kW)
2) and these prefixed units have not been "introduced" or seen before