Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict vs. permissive handling of missing/dimensionless units #32

Open
khaeru opened this issue Feb 17, 2021 · 0 comments
Open

Strict vs. permissive handling of missing/dimensionless units #32

khaeru opened this issue Feb 17, 2021 · 0 comments
Labels
discuss Under/solely for discussion enh New feature or request help wanted Extra attention is needed

Comments

@khaeru
Copy link
Owner

khaeru commented Feb 17, 2021

Consider these cases:

>>> from genno import Quantity, computations
# Case A
>>> computations.add(Quantity(1.0, units="kg"), Quantity(2.0, units="tonne), Quantity(3.0))
ValueError: Units 'kg' and '' are incompatible
# Case B
>>> computations.add(Quantity(1.0, units="kg"), Quantity(2.0, units="tonne"), Quantity(3.0, units=""))
ValueError: Units 'kg' and '' are incompatible

In (A) collect_units() assigns dimensionless to the last operand. In (B), it is explicitly dimensionless. This arose in iiasa/message_ix#441, where computations.add() is applied to two quantities, one with units, the other dimensionless (because the ixmp parameter handled by ixmp.reporting.computations.data_for_quantity() was empty).

What should the behaviour be?

Some possibilities:

  • In (A), infer that operand(s) with missing units is in the same units as the first/others. Maybe only if the units are consistent?
  • In (B), infer that explicitly dimensionless operand(s) are in the same units as the first/others.
  • Add a (global?) configuration setting to toggle between different behaviours. (What should be the default?)
@khaeru khaeru added enh New feature or request help wanted Extra attention is needed discuss Under/solely for discussion labels Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Under/solely for discussion enh New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant