issue_comments: 608391739
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/pull/3922#issuecomment-608391739 | https://api.github.com/repos/pydata/xarray/issues/3922 | 608391739 | MDEyOklzc3VlQ29tbWVudDYwODM5MTczOQ== | 14808389 | 2020-04-03T11:53:22Z | 2020-04-03T12:02:30Z | MEMBER | it seems you can't use In [25]: array.compute().argmin(dim="x") In [26]: array.argmin(dim="x")UFuncTypeError Traceback (most recent call last) <ipython-input-26-e665d5b1b9b4> in <module> ----> 1 array.argmin(dim="x") .../xarray/core/common.py in wrapped_func(self, dim, axis, skipna, kwargs) 44 45 def wrapped_func(self, dim=None, axis=None, skipna=None, kwargs): ---> 46 return self.reduce(func, dim, axis, skipna=skipna, **kwargs) 47 48 else: .../xarray/core/dataarray.py in reduce(self, func, dim, axis, keep_attrs, keepdims, kwargs) 2260 """ 2261 -> 2262 var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, kwargs) 2263 return self._replace_maybe_drop_dims(var) 2264 .../xarray/core/variable.py in reduce(self, func, dim, axis, keep_attrs, keepdims, allow_lazy, kwargs) 1573 1574 if axis is not None: -> 1575 data = func(input_data, axis=axis, kwargs) 1576 else: 1577 data = func(input_data, **kwargs) .../xarray/core/duck_array_ops.py in f(values, axis, skipna, kwargs) 302 303 try: --> 304 return func(values, axis=axis, kwargs) 305 except AttributeError: 306 if not isinstance(values, dask_array_type): .../xarray/core/duck_array_ops.py in f(args, kwargs) 45 else: 46 wrapped = getattr(eager_module, name) ---> 47 return wrapped(args, **kwargs) 48 49 else: ~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.py in wrapped(x, axis, split_every, out) 1002 1003 def wrapped(x, axis=None, split_every=None, out=None): -> 1004 return arg_reduction( 1005 x, chunk, combine, agg, axis, split_every=split_every, out=out 1006 ) ~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.py in arg_reduction(x, chunk, combine, agg, axis, split_every, out) 980 tmp = Array(graph, name, chunks, dtype=x.dtype) 981 dtype = np.argmin([1]).dtype --> 982 result = _tree_reduce(tmp, agg, axis, False, dtype, split_every, combine) 983 return handle_out(out, result) 984 ~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.py in _tree_reduce(x, aggregate, axis, keepdims, dtype, split_every, combine, name, concatenate, reduced_meta) 243 if concatenate: 244 func = compose(func, partial(_concatenate2, axes=axis)) --> 245 return partial_reduce( 246 func, 247 x, ~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.py in partial_reduce(func, x, split_every, keepdims, dtype, name, reduced_meta) 314 if is_arraylike(meta) and meta.ndim != len(out_chunks): 315 if len(out_chunks) == 0: --> 316 meta = meta.sum() 317 else: 318 meta = meta.reshape((0,) * len(out_chunks)) ~/.conda/envs/xarray/lib/python3.8/site-packages/numpy/core/_methods.py in _sum(a, axis, dtype, out, keepdims, initial, where) 36 def _sum(a, axis=None, dtype=None, out=None, keepdims=False, 37 initial=_NoValue, where=True): ---> 38 return umr_sum(a, axis, dtype, out, keepdims, initial, where) 39 40 def _prod(a, axis=None, dtype=None, out=None, keepdims=False, UFuncTypeError: ufunc 'add' cannot use operands with types dtype('<M8[ns]') and dtype('<M8[ns]')
Edit: you can reproduce it without MWE with only <tt>numpy</tt> / <tt>dask.array</tt>```python In [32]: time = np.asarray(pd.date_range("2019-07-17", periods=10)) ...: np.argmin(da.from_array(time)) --------------------------------------------------------------------------- UFuncTypeError Traceback (most recent call last) <ipython-input-32-190cb901ff65> in <module> 1 time = np.asarray(pd.date_range("2019-07-17", periods=10)) ----> 2 np.argmin(da.from_array(time)) <__array_function__ internals> in argmin(*args, **kwargs) ~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/core.py in __array_function__(self, func, types, args, kwargs) 1348 if da_func is func: 1349 return handle_nonmatching_names(func, args, kwargs) -> 1350 return da_func(*args, **kwargs) 1351 1352 @property ~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.py in wrapped(x, axis, split_every, out) 1002 1003 def wrapped(x, axis=None, split_every=None, out=None): -> 1004 return arg_reduction( 1005 x, chunk, combine, agg, axis, split_every=split_every, out=out 1006 ) ~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.py in arg_reduction(x, chunk, combine, agg, axis, split_every, out) 980 tmp = Array(graph, name, chunks, dtype=x.dtype) 981 dtype = np.argmin([1]).dtype --> 982 result = _tree_reduce(tmp, agg, axis, False, dtype, split_every, combine) 983 return handle_out(out, result) 984 ~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.py in _tree_reduce(x, aggregate, axis, keepdims, dtype, split_every, combine, name, concatenate, reduced_meta) 243 if concatenate: 244 func = compose(func, partial(_concatenate2, axes=axis)) --> 245 return partial_reduce( 246 func, 247 x, ~/.conda/envs/xarray/lib/python3.8/site-packages/dask/array/reductions.py in partial_reduce(func, x, split_every, keepdims, dtype, name, reduced_meta) 314 if is_arraylike(meta) and meta.ndim != len(out_chunks): 315 if len(out_chunks) == 0: --> 316 meta = meta.sum() 317 else: 318 meta = meta.reshape((0,) * len(out_chunks)) ~/.conda/envs/xarray/lib/python3.8/site-packages/numpy/core/_methods.py in _sum(a, axis, dtype, out, keepdims, initial, where) 36 def _sum(a, axis=None, dtype=None, out=None, keepdims=False, 37 initial=_NoValue, where=True): ---> 38 return umr_sum(a, axis, dtype, out, keepdims, initial, where) 39 40 def _prod(a, axis=None, dtype=None, out=None, keepdims=False, UFuncTypeError: ufunc 'add' cannot use operands with types dtype('<M8[ns]') and dtype('<M8[ns]') ``` </details> |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
591101988 |