Open
Description
When using the get_units
method on a Reference
to a component with units, the output is not the same as if the get_units
method was applied to the component itself. A simple example is shown below:
m = ConcreteModel()
m.var = Var([1, 2, 3, 4], units=units.m)
m.ref = Reference(m.var[:])
print(units.get_units(m.var))
>>> m
print(units.get_units(m.ref))
>>> None
Note that if applied to elements of the Reference
, the result is correct (i.e. print(units.get_units(m.ref[1])
returns m
).
In this case, the get_units
method should probably return the correct value or raise an Exception. Otherwise, this could create confusion for users.