-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
FIX Don't raise a deprecation warning for xarray.ufuncs.{angle,iscomplex} #2615
Conversation
Hello @rth! Thanks for submitting the PR.
|
'name', | ||
[name for name in dir(xu) | ||
if (not name.startswith('_') and hasattr(np, name) | ||
and name not in ['print_function', 'absolute_import', 'division'])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we list all functions defined in xarray.ufuncs
, but there are some functions that need to be filtered out.
assert isinstance(y, np.ndarray) | ||
elif name in ['frexp']: | ||
# np.frexp returns a tuple | ||
assert not isinstance(y, xr.DataArray) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output is a tuple of len 2, it's a bit of a special case, not sure if it's really worth adding specific tests for it.
'xarray.ufuncs will be deprecated when xarray no longer ' | ||
'supports versions of numpy older than v1.13. Instead, use ' | ||
'numpy ufuncs directly.', | ||
PendingDeprecationWarning, stacklevel=2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to say: "xarray.ufuncs will be deprecated when xarray no longer supports versions of numpy older than v1.17." We'll need __array_function__
from 1.17 to override angle
and iscomplex
.
Or perhaps we should just drop the pending deprecation warning entirely given how far away this is (NumPy hasn't even released 1.16 yet, nevermind 1.17)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the warning message as you suggested.
I think independently of when xarray.ufuncs
is going to be deprecated, it is good to let the user know that they can use numpy ufuncs now (for most functions except a few for which this warning is not raised)
thanks @rth ! |
* master: DEP: drop python 2 support and associated ci mods (pydata#2637) TST: silence warnings from bottleneck (pydata#2638) revert to dev version DOC: fix docstrings and doc build for 0.11.1 Source encoding always set when opening datasets (pydata#2626) Add flake check to travis (pydata#2632) Fix dayofweek and dayofyear attributes from dates generated by cftime_range (pydata#2633) silence import warning (pydata#2635) fill_value in shift (pydata#2470) Flake fixed (pydata#2629) Allow passing of positional arguments in `apply` for Groupby objects (pydata#2413) Fix failure in time encoding for pandas < 0.21.1 (pydata#2630) Fix multiindex selection (pydata#2621) Close files when CachingFileManager is garbage collected (pydata#2595) added some logic to deal with rasterio objects in addition to filepaths (pydata#2589) Get 0d slices of ndarrays directly from indexing (pydata#2625) FIX Don't raise a deprecation warning for xarray.ufuncs.{angle,iscomplex} (pydata#2615) CF: also decode time bounds when available (pydata#2571)
Closes #2609
This removes PendingDeprecationWarnings for
xarray.ufuncs.{angle,iscomplex}
which appear to not be proper ufuncs and cannot be just used from numpy for now (as discussed in the parent issue).Also adds more generic tests that numpy ufuncs do preserve the DataArray dtype.