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

Additional numpy __array_function__ implementations #6

Closed
wants to merge 10 commits into from

Conversation

jthielen
Copy link

As requested in hgrecco#764, here is a PR adding a bunch of additional numpy functions with tests.

Also, I made a few other changes that I hoped would be okay...let me know if you are okay with merging them or if I should rebase any of them out:

  • Remove the debugging print statements
  • Add DataArray to non-wrappable types
  • Adds a decorator to the tests that rely on __array_function__ to work, since it is not a guarantee it will be active
  • Change the import warning to be conditional on the __array_function__ protocol being active (since the warning seems invalid if it isn't)
  • Adds some additional test configurations to the test matrix to check that this works with old python and numpy

…nction tests

Adds a decorator so that numpy function tests are skipped when the
__array_function__ protocol is not enabled.

Adds tests for the following numpy functions operating through the
__array_function__ protocol:

- argmax
- argmin
- argsort
- max
- min
- nanmax
- nanmin
- ones_like
- shape
- zeros_like
This commit adds the following the functions via implement_func, with
tests:

alen
append
around
average
clip
copy
count_nonzero
cumprod
cumproduct
cumsum
diagonal
dot
flip
mean
median
nanargmax
nanargmin
nancumprod
nancumsum
nanmean
nanmedian
nan_to_num
nanstd
nansum
nanvar
ndim
nonzero
ptp
ravel
result_type
round_
sort
std
sum
transpose
trim_zeros
var
@jthielen
Copy link
Author

jthielen commented Sep 17, 2019

For later reference when this is likely re-implemented, see important commentary regarding searchsorted and incompatible/missing units here: pydata/xarray#3238 (comment)

Also, I think part of the original np.searchsorted issue was missed because the test was using numpy array checking, which didn't error out when units were mistakenly added to the result...another thing that will likely need a closer look upon re-implementation.

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.

1 participant