Skip to content

Commit 79e2cdd

Browse files
committed
Merge remote-tracking branch 'upstream/main' into sparse-unstack
* upstream/main: fix grammatical typo in docs (pydata#6034) Use condas dask-core in ci instead of dask to speedup ci and reduce dependencies (pydata#6007) Use complex nan by default when interpolating out of bounds (pydata#6019) Simplify missing value handling in xarray.corr (pydata#6025) Add pyXpcm to Related Projects doc page (pydata#6031) Make xr.corr and xr.map_blocks work without dask (pydata#5731)
2 parents 97e6915 + f086728 commit 79e2cdd

File tree

14 files changed

+87
-32
lines changed

14 files changed

+87
-32
lines changed

ci/requirements/doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- bottleneck
99
- cartopy
1010
- cfgrib>=0.9
11-
- dask>=2.10
11+
- dask-core>=2.30
1212
- h5netcdf>=0.7.4
1313
- ipykernel
1414
- ipython

ci/requirements/environment-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
# - cdms2 # Not available on Windows
99
# - cfgrib # Causes Python interpreter crash on Windows: https://github.com/pydata/xarray/pull/3340
1010
- cftime
11-
- dask
11+
- dask-core
1212
- distributed
1313
- fsspec!=2021.7.0
1414
- h5netcdf

ci/requirements/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- cdms2
1111
- cfgrib
1212
- cftime
13-
- dask
13+
- dask-core
1414
- distributed
1515
- fsspec!=2021.7.0
1616
- h5netcdf

ci/requirements/py37-min-all-deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- cfgrib=0.9
1717
- cftime=1.2
1818
- coveralls
19-
- dask=2.30
19+
- dask-core=2.30
2020
- distributed=2.30
2121
- h5netcdf=0.8
2222
- h5py=2.10

doc/ecosystem.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Geosciences
1313
~~~~~~~~~~~
1414

1515
- `aospy <https://aospy.readthedocs.io>`_: Automated analysis and management of gridded climate data.
16+
- `argopy <https://github.com/euroargodev/argopy>`_: xarray-based Argo data access, manipulation and visualisation for standard users as well as Argo experts.
1617
- `climpred <https://climpred.readthedocs.io>`_: Analysis of ensemble forecast models for climate prediction.
1718
- `geocube <https://corteva.github.io/geocube>`_: Tool to convert geopandas vector data into rasterized xarray data.
1819
- `GeoWombat <https://github.com/jgrss/geowombat>`_: Utilities for analysis of remotely sensed and gridded raster data at scale (easily tame Landsat, Sentinel, Quickbird, and PlanetScope).

doc/user-guide/computation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ two gaussian peaks:
546546
Broadcasting by dimension name
547547
==============================
548548

549-
``DataArray`` objects are automatically align themselves ("broadcasting" in
549+
``DataArray`` objects automatically align themselves ("broadcasting" in
550550
the numpy parlance) by dimension name instead of axis order. With xarray, you
551551
do not need to transpose arrays or insert dimensions of length 1 to get array
552552
operations to work, as commonly done in numpy with :py:func:`numpy.reshape` or

doc/whats-new.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ New Features
2626

2727
Breaking changes
2828
~~~~~~~~~~~~~~~~
29-
29+
- Use complex nan when interpolating complex values out of bounds by default (instead of real nan) (:pull:`6019`).
30+
By `Alexandre Poux <https://github.com/pums974>`_.
3031

3132
Deprecations
3233
~~~~~~~~~~~~
3334

3435

3536
Bug fixes
3637
~~~~~~~~~
38+
- :py:func:`xr.map_blocks` and :py:func:`xr.corr` now work when dask is not installed (:issue:`3391`, :issue:`5715`, :pull:`5731`).
39+
By `Gijom <https://github.com/Gijom>`_.
3740
- Fix plot.line crash for data of shape ``(1, N)`` in _title_for_slice on format_item (:pull:`5948`).
3841
By `Sebastian Weigand <https://github.com/s-weigand>`_.
3942
- Fix a regression in the removal of duplicate backend entrypoints (:issue:`5944`, :pull:`5959`)

xarray/core/computation.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,24 +1346,10 @@ def _cov_corr(da_a, da_b, dim=None, ddof=0, method=None):
13461346

13471347
# 2. Ignore the nans
13481348
valid_values = da_a.notnull() & da_b.notnull()
1349+
da_a = da_a.where(valid_values)
1350+
da_b = da_b.where(valid_values)
13491351
valid_count = valid_values.sum(dim) - ddof
13501352

1351-
def _get_valid_values(da, other):
1352-
"""
1353-
Function to lazily mask da_a and da_b
1354-
following a similar approach to
1355-
https://github.com/pydata/xarray/pull/4559
1356-
"""
1357-
missing_vals = np.logical_or(da.isnull(), other.isnull())
1358-
if missing_vals.any():
1359-
da = da.where(~missing_vals)
1360-
return da
1361-
else:
1362-
return da
1363-
1364-
da_a = da_a.map_blocks(_get_valid_values, args=[da_b])
1365-
da_b = da_b.map_blocks(_get_valid_values, args=[da_a])
1366-
13671353
# 3. Detrend along the given dim
13681354
demeaned_da_a = da_a - da_a.mean(dim=dim)
13691355
demeaned_da_b = da_b - da_b.mean(dim=dim)

xarray/core/missing.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ def __init__(self, xi, yi, method="linear", fill_value=None, period=None):
8282
self._xi = xi
8383
self._yi = yi
8484

85+
nan = np.nan if yi.dtype.kind != "c" else np.nan + np.nan * 1j
86+
8587
if fill_value is None:
86-
self._left = np.nan
87-
self._right = np.nan
88+
self._left = nan
89+
self._right = nan
8890
elif isinstance(fill_value, Sequence) and len(fill_value) == 2:
8991
self._left = fill_value[0]
9092
self._right = fill_value[1]
@@ -143,10 +145,12 @@ def __init__(
143145
self.cons_kwargs = kwargs
144146
self.call_kwargs = {}
145147

148+
nan = np.nan if yi.dtype.kind != "c" else np.nan + np.nan * 1j
149+
146150
if fill_value is None and method == "linear":
147-
fill_value = np.nan, np.nan
151+
fill_value = nan, nan
148152
elif fill_value is None:
149-
fill_value = np.nan
153+
fill_value = nan
150154

151155
self.f = interp1d(
152156
xi,

xarray/core/parallel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .alignment import align
2424
from .dataarray import DataArray
2525
from .dataset import Dataset
26+
from .pycompat import is_dask_collection
2627

2728
try:
2829
import dask
@@ -328,13 +329,13 @@ def _wrapper(
328329
raise TypeError("kwargs must be a mapping (for example, a dict)")
329330

330331
for value in kwargs.values():
331-
if dask.is_dask_collection(value):
332+
if is_dask_collection(value):
332333
raise TypeError(
333334
"Cannot pass dask collections in kwargs yet. Please compute or "
334335
"load values before passing to map_blocks."
335336
)
336337

337-
if not dask.is_dask_collection(obj):
338+
if not is_dask_collection(obj):
338339
return func(obj, *args, **kwargs)
339340

340341
all_args = [obj] + list(args)

0 commit comments

Comments
 (0)