🌐 AI搜索 & 代理 主页
Skip to content

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