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 with units returns True for __eq__ with plain numpy array #146

Open
bjodah opened this issue Jan 28, 2018 · 1 comment · May be fixed by #147
Open

Quantity with units returns True for __eq__ with plain numpy array #146

bjodah opened this issue Jan 28, 2018 · 1 comment · May be fixed by #147

Comments

@bjodah
Copy link
Contributor

bjodah commented Jan 28, 2018

Consider this:

In [10]: 2.1*pq.m == np.array(2.1)
Out[10]: True

I would have expected it to return True only if the Quantity instance was dimensionless.
What do others think?

EDIT:
since the numbers (arrays) cannot be added to each other, I think it really should be an error:

>>> 3*pq.m + 3
ValueError ...
@apdavison
Copy link
Contributor

apdavison commented Jan 29, 2018

Similarly,

In [4]: [2.1, 2.2]*pq.m == np.array([2.1, 2.2])
Out[4]: array([ True,  True], dtype=bool)

I think this behaviour should be changed, but it would be a major change, potentially affecting a lot of downstream libraries, so an extended period with deprecation warnings would be needed.

Please can other people chime in with their opinion?

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

Successfully merging a pull request may close this issue.

2 participants