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

Change comparison of Quantity (to fix gh-146) #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bjodah
Copy link
Contributor

@bjodah bjodah commented Jan 28, 2018

This fixes gh-146 (Quantity with dimension comparing equal to plain numpy arrays).
This is a rather big change since it actually changes some tests to expect errors being raised where equality was assumed before. So we might need a deprecation cycle (we can emit warnings where we will raise exceptions / change equality behaviour). Or maybe people even find the change to be too large to even be considered?

What do people think?

@apdavison
Copy link
Contributor

I just ran the test suite for the Neo core module with this branch, and got

Ran 639 tests in 6.334s

FAILED (errors=35, failures=9)

so I think we can conclude this will indeed break a lot of things.

I do think this is something we should move towards, but we need to move slowly to avoid breaking downstream code unexpectedly. I suggest adding a global flag, e.g. QUANTITY_EQUALS_ARRAY which we would set to True by default. If True, then such comparisons will raise DeprecationWarning, if False they will raise ValueError as in this PR.

In six months or so we can set the global flag to False by default, so that people can still get the old behaviour if they prefer.

What do you think?

@bjodah
Copy link
Contributor Author

bjodah commented Jul 2, 2018

Yes, making the new behavior "opt-in" for a long time using an environment variable sounds like to right approach.

I might get back to this PR later, but if anyone wants to implement this sooner: feel free to continue off this branch.

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 this pull request may close these issues.

Quantity with units returns True for __eq__ with plain numpy array
2 participants