Open nusbaume opened 5 months ago
Another alternative would be to add the conversion to unit_conversion.py but have the conversion return an empty string for both the forward and reverse transforms. Then, modify has_unit_transforms
to detect this and return False
for this case. This might be as easy as just changing the return
statement to:
return self.__unit_transforms is not None and self.__unit_transforms[0]
@gold2718 I like that idea. Nice and neat. See https://github.com/NCAR/ccpp-framework/pull/571
Description
There are situations where two sets of units are mathematically equivalent even though the actual
units
text might be different (for examplem2 s-2
andJ kg-1
). Currently this results in an error being thrown stating that units don't match, but it would be nice for the framework to instead recognize that the units are actually equivalent and let the cap generation continue.Solution
Ideally it might be good to have a dictionary somewhere that indicates which units are equivalent to each other. Then the dictionary can be queried to see if the "different" units are okay, or if they are in fact a mismatch.
Alternatives (optional)
A simpler alternative could be to just add a new no-op unit conversion for each one of these equivalent pairs (e.g. just multiply the units by one). This would avoid having to add any new infrastructure to the framework itself beyond just the new unit conversion function.