Uh oh!
There was an error while loading. Please reload this page.
FIX: correct dask array handling in _calc_idxminmax - #3922
Conversation
Hello @kmuehlbauer! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-05-09 14:03:57 UTC |
| if isinstance(array.data, dask_array_type): | ||
| res = array.map_blocks( | ||
| lambda a, b: a[b], coordarray, indx, dtype=indx.dtype | ||
| ).compute() |
There was a problem hiding this comment.
What breaks if you don't compute?
There was a problem hiding this comment.
further down, this will break:
# The dim is gone but we need to remove the corresponding coordinate.delres.coords[dim]
# Copy attributes from argmin/argmax, if anyres.attrs=indx.attrsThere was a problem hiding this comment.
My dask-knowledge lacks, so I was not able to come up with a better solution, unfortunately
There was a problem hiding this comment.
ah this was quite broken. I just pushed a commit. Please see if that works. Clearly we need to add some tests with dask-backed objects.
There was a problem hiding this comment.
@dcherian Thanks, I'll have a look first thing next morning (CET).
kmuehlbauer
commented
Apr 1, 2020
@dcherian This seemed to work until computation: where Full Traceback: /home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/xarray/core/dataarray.pyincompute(self, **kwargs)
839""" 840 new = self.copy(deep=False)--> 841 return new.load(**kwargs) 842 843 def persist(self, **kwargs) -> "DataArray":/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/xarray/core/dataarray.py in load(self, **kwargs) 813 dask.array.compute 814 """-->815ds=self._to_temp_dataset().load(**kwargs)
816new=self._from_temp_dataset(ds)
817self._variable=new._variable/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/xarray/core/dataset.pyinload(self, **kwargs)
654655# evaluate all the dask arrays simultaneously-->656evaluated_data=da.compute(*lazy_data.values(), **kwargs)
657658fork, datainzip(lazy_data, evaluated_data):
/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/dask/base.pyincompute(*args, **kwargs)
435keys= [x.__dask_keys__() forxincollections]
436postcomputes= [x.__dask_postcompute__() forxincollections]
-->437results=schedule(dsk, keys, **kwargs)
438returnrepack([f(r, *a) forr, (f, a) inzip(results, postcomputes)])
439/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/dask/threaded.pyinget(dsk, result, cache, num_workers, pool, **kwargs)
74pools[thread][num_workers] =pool75--->76results=get_async(
77pool.apply_async,
78len(pool._pool),
/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/dask/local.pyinget_async(apply_async, num_workers, dsk, result, cache, get_id, rerun_exceptions_locally, pack_exception, raise_exception, callbacks, dumps, loads, **kwargs)
484_execute_task(task, data) # Re-execute locally485else:
-->486raise_exception(exc, tb)
487res, worker_id=loads(res_info)
488state["cache"][key] =res/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/dask/local.pyinreraise(exc, tb)
314ifexc.__traceback__isnottb:
315raiseexc.with_traceback(tb)
-->316raiseexc317318/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/dask/local.pyinexecute_task(key, task_info, dumps, loads, get_id, pack_exception)
220try:
221task, data=loads(task_info)
-->222result=_execute_task(task, data)
223id=get_id()
224result=dumps((result, id))
/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/dask/core.pyin_execute_task(arg, cache, dsk)
119# temporaries by their reference count and can execute certain120# operations in-place.-->121returnfunc(*(_execute_task(a, cache) forainargs))
122elifnotishashable(arg):
123returnarg/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/dask/optimization.pyin__call__(self, *args)
980ifnotlen(args) ==len(self.inkeys):
981raiseValueError("Expected %d args, got %d"% (len(self.inkeys), len(args)))
-->982returncore.get(self.dsk, self.outkey, dict(zip(self.inkeys, args)))
983984def__reduce__(self):
/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/dask/core.pyinget(dsk, out, cache)
149forkeyintoposort(dsk):
150task=dsk[key]
-->151result=_execute_task(task, cache)
152cache[key] =result153result=_execute_task(out, cache)
/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/dask/core.pyin_execute_task(arg, cache, dsk)
119# temporaries by their reference count and can execute certain120# operations in-place.-->121returnfunc(*(_execute_task(a, cache) forainargs))
122elifnotishashable(arg):
123returnarg/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/xarray/core/computation.pyin<lambda>(ind, coord)
1387res=indx.copy(
1388data=indx.data.map_blocks(
->1389lambdaind, coord: coord[(ind,)], coordarray, dtype=coordarray.dtype1390 )
1391 )
/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/xarray/core/dataarray.pyin__getitem__(self, key)
642else:
643# xarray-style array indexing-->644returnself.isel(indexers=self._item_key_to_dict(key))
645646def__setitem__(self, key: Any, value: Any) ->None:
/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/xarray/core/dataarray.pyinisel(self, indexers, drop, **indexers_kwargs)
1020indexers=either_dict_or_kwargs(indexers, indexers_kwargs, "isel")
1021ifany(is_fancy_indexer(idx) foridxinindexers.values()):
->1022ds=self._to_temp_dataset()._isel_fancy(indexers, drop=drop)
1023returnself._from_temp_dataset(ds)
1024/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/xarray/core/dataset.pyin_isel_fancy(self, indexers, drop)
1962# Note: we need to preserve the original indexers variable in order to merge the1963# coords below->1964indexers_list=list(self._validate_indexers(indexers))
19651966variables: Dict[Hashable, Variable] = {}
/home/kai/miniconda/envs/wradlib_38_01/lib/python3.8/site-packages/xarray/core/dataset.pyin_validate_indexers(self, indexers)
18051806ifv.ndim>1:
->1807raiseIndexError(
1808"Unlabeled multi-dimensional array cannot be "1809"used for indexing: {}".format(k)
IndexError: Unlabeledmulti-dimensionalarraycannotbeusedforindexing: array_bin |
max-sixty
commented
Apr 2, 2020
@kmuehlbauer what's the code that's running to generate that traceback? I can try and help in lieu of @dcherian Thanks for giving this a go And CC @toddrjen if they have any insight |
@max-sixty Thanks! I'll really appreciate your help. I've tracked the possible source down to a dimension problem. I've tried to create a minimal example as follows using the current # create dask backed 3d arraydarray=da.from_array(np.random.RandomState(0).randn(10*20*30).reshape(10, 20, 30), chunks=(10, 20, 30), name='data_arr')
array=xr.DataArray(darray, dims=["x", "y", 'z'])
array=array.assign_coords({'x': (['x'], np.arange(10)),
'y': (['y'], np.arange(20)),
'z': (['z'], np.arange(30)),
})
func=lambdax, *args, **kwargs: x.argmax(*args, **kwargs)
indx=func(array, dim='z', axis=None, keep_attrs=True, skipna=False)
coordarray=array['z']
res=indx.copy(
data=indx.data.map_blocks(
lambdaind, coord: coord[(ind,)], coordarray, dtype=coordarray.dtype
)
)
print(res)
# the following line break breaksprint(res.compute())
# using only 2dim array everything works as intendedarray2d=array.sel(y=0, drop=True)
indx=func(array2d, dim='z', axis=None, keep_attrs=True, skipna=False)
coordarray=array['z']
res=indx.copy(
data=indx.data.map_blocks(
lambdaind, coord: coord[(ind,)], coordarray, dtype=coordarray.dtype
)
)
print(res)
# this works for two dim dataprint(res.compute()) |
keewis
commented
Apr 3, 2020
The issue is that To get your 3D example (and potentially every N-D example) to work, simply fall back to the wrapped array's integer indexing (using In [2]: darray=da.from_array( ...: np.random.RandomState(0).randn(10*20*30).reshape(10, 20, 30), ...: chunks=(1, 20, 30), # so we actually have multiple blocks
...: name='data_arr' ...: ) ...: array=xr.DataArray( ...: darray, ...: dims=["x", "y", 'z'], ...: coords={"x": np.arange(10), "y": np.arange(20), "z": np.arange(30)}, ...: ) ...: arrayOut[2]: <xarray.DataArray'data_arr' (x: 10, y: 20, z: 30)>dask.array<data_arr, shape=(10, 20, 30), dtype=float64, chunksize=(1, 20, 30), chunktype=numpy.ndarray>Coordinates:
*x (x) int640123456789*y (y) int64012345678910111213141516171819*z (z) int64012345678910 ... 20212223242526272829In [3]: indx=array.argmin(dim='z', keep_attrs=True, skipna=False) ...: res=indx.copy( ...: data=indx.data.map_blocks( ...: lambdaind, coord: coord[(ind,)], ...: array.z.data, ...: dtype=array.z.dtype ...: ) ...: )
In [4]: res.compute()
Out[4]: <xarray.DataArray'data_arr' (x: 10, y: 20)>array([[20, 3, 3, 11, 20, 17, 3, 27, 24, 1, 7, 4, 22, 14, 7, 18,
5, 18, 7, 19],
[10, 21, 25, 3, 15, 25, 28, 8, 10, 9, 13, 3, 24, 17, 19, 23,
12, 19, 19, 28],
[ 1, 26, 10, 9, 16, 8, 17, 8, 6, 24, 28, 13, 23, 22, 26, 13,
28, 11, 6, 16],
[ 6, 9, 26, 27, 1, 2, 21, 8, 10, 19, 14, 14, 20, 25, 24, 4,
18, 12, 20, 2],
[22, 5, 12, 17, 13, 23, 23, 8, 27, 22, 1, 19, 26, 16, 12, 17,
19, 28, 8, 12],
[20, 8, 25, 13, 4, 12, 23, 13, 27, 18, 15, 28, 10, 10, 0, 12,
5, 14, 5, 27],
[29, 0, 19, 7, 15, 2, 8, 8, 13, 4, 12, 1, 7, 19, 14, 0,
3, 7, 12, 9],
[ 9, 8, 4, 9, 17, 6, 7, 5, 29, 0, 15, 28, 22, 6, 24, 24,
20, 0, 24, 23],
[ 1, 19, 12, 20, 4, 26, 5, 13, 21, 26, 25, 10, 5, 1, 11, 21,
6, 18, 4, 21],
[15, 27, 13, 7, 25, 3, 14, 14, 17, 15, 11, 4, 16, 22, 22, 23,
0, 16, 26, 13]])
Coordinates:
*x (x) int640123456789*y (y) int64012345678910111213141516171819Note that in this case |
kmuehlbauer
commented
Apr 3, 2020
@keewis Thanks a bunch for the explanation. Would we be on the safe side, if we use your proposed N-D example? It also works in the 2d-case. |
keewis
commented
Apr 3, 2020
👍 |
kmuehlbauer
commented
Apr 3, 2020
@keewis I checked with my datasets, works like a charm. I'll try to add dask tests for this as @shoyer suggested. Where should these tests go? Currently the idxmax/idxmin tests are in test_dataarray and test_dataset: xarray/xarray/tests/test_dataarray.py Line 4512 in b3bafee xarray/xarray/tests/test_dataarray.py Line 4608 in b3bafee xarray/xarray/tests/test_dataset.py Lines 4603 to 4610 in 1416d5a Any pointers? |
I'd put the Edit: that's easy for |
kmuehlbauer
commented
Apr 3, 2020
@keewis I've started by adding the dask tests to the existing |
it seems you can't use In [24]: time=np.asarray(pd.date_range("2019-07-17", periods=10)) ...: array=xr.DataArray( ...: time, ...: dims="x", ...: coords={"x": np.arange(time.size) *4}, ...: ).chunk({}) ...: arrayOut[24]: <xarray.DataArray (x: 10)>dask.array<xarray-<this-array>, shape=(10,), dtype=datetime64[ns], chunksize=(10,), chunktype=numpy.ndarray>Coordinates:
*x (x) int6404812162024283236In [25]: array.compute().argmin(dim="x") Out[25]: <xarray.DataArray ()>array(0)
In [26]: array.argmin(dim="x") ---------------------------------------------------------------------------UFuncTypeErrorTraceback (mostrecentcalllast)
<ipython-input-26-e665d5b1b9b4>in<module>---->1array.argmin(dim="x")
.../xarray/core/common.pyinwrapped_func(self, dim, axis, skipna, **kwargs)
4445defwrapped_func(self, dim=None, axis=None, skipna=None, **kwargs):
--->46returnself.reduce(func, dim, axis, skipna=skipna, **kwargs)
4748else:
.../xarray/core/dataarray.pyinreduce(self, func, dim, axis, keep_attrs, keepdims, **kwargs)
2260 """
2261->2262var=self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
2263returnself._replace_maybe_drop_dims(var)
2264 .../xarray/core/variable.pyinreduce(self, func, dim, axis, keep_attrs, keepdims, allow_lazy, **kwargs)
15731574ifaxisisnotNone:
->1575data=func(input_data, axis=axis, **kwargs)
1576else:
1577data=func(input_data, **kwargs)
.../xarray/core/duck_array_ops.pyinf(values, axis, skipna, **kwargs)
302303try:
-->304returnfunc(values, axis=axis, **kwargs)
305exceptAttributeError:
306ifnotisinstance(values, dask_array_type):
.../xarray/core/duck_array_ops.pyinf(*args, **kwargs)
45else:
46wrapped=getattr(eager_module, name)
--->47returnwrapped(*args, **kwargs)
4849else:
~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.pyinwrapped(x, axis, split_every, out)
10021003defwrapped(x, axis=None, split_every=None, out=None):
->1004returnarg_reduction(
1005x, chunk, combine, agg, axis, split_every=split_every, out=out1006 )
~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.pyinarg_reduction(x, chunk, combine, agg, axis, split_every, out)
980tmp=Array(graph, name, chunks, dtype=x.dtype)
981dtype=np.argmin([1]).dtype-->982result=_tree_reduce(tmp, agg, axis, False, dtype, split_every, combine)
983returnhandle_out(out, result)
984~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.pyin_tree_reduce(x, aggregate, axis, keepdims, dtype, split_every, combine, name, concatenate, reduced_meta)
243ifconcatenate:
244func=compose(func, partial(_concatenate2, axes=axis))
-->245returnpartial_reduce(
246func,
247x,
~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.pyinpartial_reduce(func, x, split_every, keepdims, dtype, name, reduced_meta)
314ifis_arraylike(meta) andmeta.ndim!=len(out_chunks):
315iflen(out_chunks) ==0:
-->316meta=meta.sum()
317else:
318meta=meta.reshape((0,) *len(out_chunks))
~/.conda/envs/xarray/lib/python3.8/site-packages/numpy/core/_methods.pyin_sum(a, axis, dtype, out, keepdims, initial, where)
36def_sum(a, axis=None, dtype=None, out=None, keepdims=False,
37initial=_NoValue, where=True):
--->38returnumr_sum(a, axis, dtype, out, keepdims, initial, where)
3940def_prod(a, axis=None, dtype=None, out=None, keepdims=False,
UFuncTypeError: ufunc'add'cannotuseoperandswithtypesdtype('<M8[ns]') anddtype('<M8[ns]')I guess that's a Edit: you can reproduce it without MWE with only numpy / dask.arrayIn [32]: time=np.asarray(pd.date_range("2019-07-17", periods=10)) ...: np.argmin(da.from_array(time)) ---------------------------------------------------------------------------UFuncTypeErrorTraceback (mostrecentcalllast)
<ipython-input-32-190cb901ff65>in<module>1time=np.asarray(pd.date_range("2019-07-17", periods=10))
---->2np.argmin(da.from_array(time))
<__array_function__internals>inargmin(*args, **kwargs)
~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/core.pyin__array_function__(self, func, types, args, kwargs)
1348ifda_funcisfunc:
1349returnhandle_nonmatching_names(func, args, kwargs)
->1350returnda_func(*args, **kwargs)
13511352 @property~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.pyinwrapped(x, axis, split_every, out)
10021003defwrapped(x, axis=None, split_every=None, out=None):
->1004returnarg_reduction(
1005x, chunk, combine, agg, axis, split_every=split_every, out=out1006 )
~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.pyinarg_reduction(x, chunk, combine, agg, axis, split_every, out)
980tmp=Array(graph, name, chunks, dtype=x.dtype)
981dtype=np.argmin([1]).dtype-->982result=_tree_reduce(tmp, agg, axis, False, dtype, split_every, combine)
983returnhandle_out(out, result)
984~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.pyin_tree_reduce(x, aggregate, axis, keepdims, dtype, split_every, combine, name, concatenate, reduced_meta)
243ifconcatenate:
244func=compose(func, partial(_concatenate2, axes=axis))
-->245returnpartial_reduce(
246func,
247x,
~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.pyinpartial_reduce(func, x, split_every, keepdims, dtype, name, reduced_meta)
314ifis_arraylike(meta) andmeta.ndim!=len(out_chunks):
315iflen(out_chunks) ==0:
-->316meta=meta.sum()
317else:
318meta=meta.reshape((0,) *len(out_chunks))
~/.conda/envs/xarray/lib/python3.8/site-packages/numpy/core/_methods.pyin_sum(a, axis, dtype, out, keepdims, initial, where)
36def_sum(a, axis=None, dtype=None, out=None, keepdims=False,
37initial=_NoValue, where=True):
--->38returnumr_sum(a, axis, dtype, out, keepdims, initial, where)
3940def_prod(a, axis=None, dtype=None, out=None, keepdims=False,
UFuncTypeError: ufunc'add'cannotuseoperandswithtypesdtype('<M8[ns]') anddtype('<M8[ns]') |
kmuehlbauer
commented
Apr 3, 2020
@keewis OK, how should I handle this? Shall we XFAIL the these tests then? |
keewis
commented
Apr 3, 2020
I think so? For now, xfail if |
…ray, xfail dask tests for dtype dateime64 (M)
kmuehlbauer
commented
Apr 3, 2020
Seems that everything goes well, besides the If this is ready for merge, should I extend the idxmin/idxmax section of whats-new.rst ? And how should I distribute the credit for all contributors @dcherian, @keewis, @max-sixty? |
keewis
commented
Apr 3, 2020
I'd say add a new entry. Also, I think we're all just reviewers so adding just your name should be fine. |
kmuehlbauer
commented
Apr 6, 2020
This is ready from my end for final review. Should be merged before #3936, IMHO. |
dcherian
commented
Apr 14, 2020
If your tests are passing now, it's likely that they're computing things to make things work. We should add the |
kmuehlbauer
commented
Apr 14, 2020
@dcherian Thanks for the suggestion with the dask compute context, I'll have a look the next day. Nevertheless, I've debugged locally and the res-output of the idxmin/idxmax holds dask data. Anyway, I'll revert to the former working status and leave a comment to this PR in the code. |
dcherian
commented
Apr 14, 2020
I suggest updating the tests before reverting anything. This solution may work ... |
kmuehlbauer
commented
Apr 15, 2020
@dcherian I've tried to apply the I'm now totally unsure how to proceed from here. Any guidance very much appreciated. |
dcherian
commented
Apr 15, 2020
@kmuehlbauer I've pushed a commit adding the decorator to just the 2D
I think @shoyer is right here. |
kmuehlbauer
commented
Apr 15, 2020
@dcherian Thanks for explaining the decorator a bit more. So it's indeed simpler than I thought. I'll revert to the |
dcherian
commented
Apr 15, 2020
Not a problem. Thanks for working on this! |
shoyer
commented
Apr 16, 2020
A simpler option than using |
…ask_computes()` context to idxmin-tests
kmuehlbauer
commented
Apr 16, 2020
@shoyer Thanks for the hint. I'm currently experimenting with the different possibilities. non-dask: dask: The relevant code inside idxmin/idxmax: # This will run argmin or argmax.# indx will be dask if array is daskindx=func(array, dim=dim, axis=None, keep_attrs=keep_attrs, skipna=skipna)
# separated out for debugging# with the current test layout coords will not be dask since the array's coords are not daskcoords=array[dim]
# try to make dask of coords as per @shoyer's suggestion # the below fails silently, but cannot be forced even with trying to # do something like dask.array.asarray(), this errors out with# "Cannot assign to the .data attribute of dimension coordinate a.k.a IndexVariable 'x'"ifisinstance(indx.data, dask_array_type):
coords=coords.chunk({})
res=coords[(indx,)]It seems that the map-blocks approach is the only one which seem to work throughout the tests, but one. It fails with array set as array.astype("object") in the test fixture. Reason: dask gets computed within argmin/argmax. I'll revert to the map-blocks now and add the |
kmuehlbauer
commented
Apr 16, 2020
Error log of the compute error: Details |
dcherian
commented
Apr 18, 2020
Yeah interestingly we don't raise an error when trying to chunk IndexVariables. I've pushed a commit where we extract the underlying numpy array, chunk that, index it and then wrap it up in a DataArray o_O. |
The compute error is from here: Lines 48 to 60 in 6a6f2c8 I think we'll have to rethink the skipna conditions for dask arrays so that the compute doesn't happen. Or figure out why we do this check in the first place. hmm... |
This reverts commit 58901b9.
…k-issues * upstream/master: (22 commits) support darkmode (pydata#4036) Use literal syntax instead of function calls to create the data structure (pydata#4038) Add template xarray object kwarg to map_blocks (pydata#3816) Transpose coords by default (pydata#3824) Remove broken test for Panel with to_pandas() (pydata#4028) Allow warning with cartopy in docs plotting build (pydata#4032) Support overriding existing variables in to_zarr() without appending (pydata#4029) chore: Remove unnecessary comprehension (pydata#4026) fix to_netcdf docstring typo (pydata#4021) Pint support for DataArray (pydata#3643) Apply blackdoc to the documentation (pydata#4012) ensure Variable._repr_html_ works (pydata#3973) Fix handling of abbreviated units like msec (pydata#3998) full_like: error on non-scalar fill_value (pydata#3979) Fix some code quality and bug-risk issues (pydata#3999) DOC: add pandas.DataFrame.to_xarray (pydata#3994) Better chunking error messages for zarr backend (pydata#3983) Silence sphinx warnings (pydata#3990) Fix distributed tests on upstream-dev (pydata#3989) Add multi-dimensional extrapolation example and mention different behavior of kwargs in interp (pydata#3956) ...
The test fails for object arrays because we compute eagerly in To solve this we could
For now, I bumped up |
kmuehlbauer
commented
May 9, 2020
Thanks @dcherian for getting back to this. To my bad, this adventure went too far for my capabilities. Nevertheless I hope to catch up learning xarray inside. |
* Added chunks='auto' option in dataset.py * FIX: correct dask array handling in _calc_idxminmax (#3922) * FIX: correct dask array handling in _calc_idxminmax * FIX: remove unneeded import, reformat via black * fix idxmax, idxmin with dask arrays * FIX: use array[dim].data in `_calc_idxminmax` as per @keewis suggestion, attach dim name to result * ADD: add dask tests to `idxmin`/`idxmax` dataarray tests * FIX: add back fixture line removed by accident * ADD: complete dask handling in `idxmin`/`idxmax` tests in test_dataarray, xfail dask tests for dtype dateime64 (M) * ADD: add "support dask handling for idxmin/idxmax" in whats-new.rst * MIN: reintroduce changes added by #3953 * MIN: change if-clause to use `and` instead of `&` as per review-comment * MIN: change if-clause to use `and` instead of `&` as per review-comment * WIP: remove dask handling entirely for debugging purposes * Test for dask computes * WIP: re-add dask handling (map_blocks-approach), add `with raise_if_dask_computes()` context to idxmin-tests * Use dask indexing instead of map_blocks. * Better chunk choice. * Return -1 for _nan_argminmax_object if all NaNs along dim * Revert "Return -1 for _nan_argminmax_object if all NaNs along dim" This reverts commit 58901b9. * Raise error for object arrays * No error for object arrays. Instead expect 1 compute in tests. Co-authored-by: dcherian <deepak@cherian.net> * fix the failing flake8 CI (#4057) * rename d and l to dim and length * Fixed typo in rasterio docs (#4063) * Added chunks='auto' option in dataset.py Added changes to whats-new.rst * Added chunks='auto' option in dataset.py Added changes to whats-new.rst * Error fix, catch chunks=None * Minor reformatting + flake8 changes * Added isinstance(chunks, (Number, str)) in dataset.py, passing * format changes * added auto-chunk test for dataarrays * Assert chunk sizes equal in auto-chunk test Co-authored-by: Kai Mühlbauer <kmuehlbauer@users.noreply.github.com> Co-authored-by: dcherian <deepak@cherian.net> Co-authored-by: keewis <keewis@users.noreply.github.com> Co-authored-by: clausmichele <31700619+clausmichele@users.noreply.github.com> Co-authored-by: Keewis <keewis@posteo.de>
Fixes dask handling for implementation in #3871.
isort -rc . && black . && mypy . && flake8whats-new.rstfor all changes andapi.rstfor new API