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

Quantity Object returns wrong values if max_val >> value (or min_val << value) #147

Open
MaxNaeg opened this issue Nov 9, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@MaxNaeg
Copy link
Contributor

MaxNaeg commented Nov 9, 2021

Describe the bug

If the min or max value of a Quantity object are set to a very different order of magnitude compared to the actual value, the normalized value that is stored is very close to zero/one. When trying to recover the original value with get_value() machine imprecision leads to a completely wrong result.

To Reproduce

Quantity(10e9,min_val=0e9, max_val=10e30).get_value() will give 0

Expected behavior

Quantity(10e9,min_val=0e9, max_val=10e30).get_value() should return 10e9

Environment

  • OS: ubuntu18
  • Python Version: 3.8
@lazyoracle lazyoracle added the bug Something isn't working label Nov 9, 2021
@nwittler
Copy link
Collaborator

This is a precision error from applying a transform from physical range to [-1, 1]. It has not been working properly if you exactly hit the bound, too, so the corresponding methods (e.g.

c3/c3/c3objs.py

Line 256 in 5f20637

def set_value(self, val, extend_bounds=False) -> None:
) should be reworked. Till then, a workaround is to not set huge bounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants