-
Notifications
You must be signed in to change notification settings - Fork 49
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
Lack of precision can cause incorrect conversions #380
Comments
The thing here that worries me is that 1e13 msun in those units is ~677, far, far, far from the precision limit in the array! |
Maybe you want to use a
|
I see that this works, but I am not sure why? There is enough precision 'in the system' here to do all unit conversions... Why do I get an array full of 1s when I do the comparison? |
The issue is that
Not sure what this is referring to. |
Ah so everything is converted to kg, and then compared? This is not ideal, you're right. |
Would it make sense to convert the LHS and RHS to the largest common denominator of the same unit (here mass) to do the comparison? |
Maybe? There would likely be a performance cost to do that check. Currently no effort is made to avoid overflows when doing these sorts of conversions. |
Surely it would be cheaper? As you only have to convert one of the items rather than both?
|
This has also become an issue for us on another project using galactic scale (> 1e10 Msun) masses. The solution was to use the galactic base class directly on the units themselves, rather than converting the composite
For Josh's example above, you need to consistently use this whenever the units are referenced
Output:
|
Description
When working with data in float32 around 1e10 (far from precision limit), unyt incorrectly converts units:
What I Did
Output
These units might seem weird, but they are pretty much what just comes out of typical h and a-dependent 1e10 Msun units... As the 'value' version shows, this should work!
The text was updated successfully, but these errors were encountered: