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

Need mechanism to support equivalent units #570

Open
nusbaume opened this issue Jun 14, 2024 · 2 comments
Open

Need mechanism to support equivalent units #570

nusbaume opened this issue Jun 14, 2024 · 2 comments

Comments

@nusbaume
Copy link
Collaborator

Description

There are situations where two sets of units are mathematically equivalent even though the actual units text might be different (for example m2 s-2 and J 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.

@gold2718
Copy link
Collaborator

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]

@dustinswales
Copy link
Collaborator

@gold2718 I like that idea. Nice and neat.
See #571

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants