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

Support for numpy.allclose #978

Closed
SimonBoothroyd opened this issue Jan 8, 2020 · 2 comments · Fixed by #979
Closed

Support for numpy.allclose #978

SimonBoothroyd opened this issue Jan 8, 2020 · 2 comments · Fixed by #979
Milestone

Comments

@SimonBoothroyd
Copy link

SimonBoothroyd commented Jan 8, 2020

It seems pint > 0.10 loses support for numpy.allclose. Running

from pint import Unit
import numpy as np

x = np.array([1, 2, 3]) * Unit("kelvin")
np.allclose(x, x)

yields

TypeError: no implementation found for 'numpy.allclose' on types that implement __array_function__: [<class 'pint.quantity.build_quantity_class.<locals>.Quantity'>]

I'm guessing this was just missed by #905? Happy to submit a PR / test if this is the case.

@keewis
Copy link
Contributor

keewis commented Jan 8, 2020

I don't think np.allclose was ever supported. The only change between 0.9 and 0.10 is that it does not fall back to the magnitude anymore. This:

In [3]: x = np.arange(5) * ureg.m 
   ...: y = x.to(ureg.mm) 
   ...: np.allclose(x, y)                                                                                                                                                                                                       
.../pint/pint/quantity.py:1377: UnitStrippedWarning: The unit of the quantity is stripped.
  warnings.warn("The unit of the quantity is stripped.", UnitStrippedWarning)
Out[3]: False

shows the problems with that approach.

That said, I think it was just missed before.

@hgrecco
Copy link
Owner

hgrecco commented Jan 9, 2020

It would be good to use this into account when tackling #947

@hgrecco hgrecco added this to the 0.11 milestone Jan 9, 2020
@bors bors bot closed this as completed in 2da1be7 Jan 9, 2020
@bors bors bot closed this as completed in #979 Jan 9, 2020
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.

3 participants