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

Scalars should compare equal if the underlying quantity measure is OK #26

Open
nicoddemus opened this issue Aug 28, 2019 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@nicoddemus
Copy link
Member

nicoddemus commented Aug 28, 2019

I think Scalar(1, "m") should compare equal to Scalar(100, "cm"). This would allow us to write more natural code like:

if current_tubing_end <= current_open_hole_position:

Instead of being forced to write:

if current_tubing_end.GetValue('m') <= current_open_hole_position.GetValue('m'):

pint works this way:

>>> import pint
>>> ureg = pint.UnitRegistry()
>>> 1* ureg.meter == 100 * ureg.centimeter
True

From this discussion: https://eden.esss.com.br/stash/projects/ESSS/repos/alfasim/pull-requests/1690/overview?commentId=120265

@nicoddemus nicoddemus added the enhancement New feature or request label Aug 28, 2019
@nicoddemus
Copy link
Member Author

Another annoying side-effect:

>>> {Scalar(1,'m'), Scalar(100, 'cm')}
{Scalar(1.0, 'm', 'length'), Scalar(100.0, 'cm', 'length')}

This should have returned:

>>> {Scalar(1,'m'), Scalar(100, 'cm')}
{Scalar(1.0, 'm', 'length')}

@prusse-martin
Copy link
Member

and

>>> {Scalar(100, 'cm'), Scalar(1,'m')}
{Scalar(100.0, 'cm', 'length')}
>>> {Scalar(100.0, 'cm', 'length')} == {Scalar(1.0, 'm', 'length')}
True

?

This will make the scalar hash being a bit slower.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants