home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1221642349

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/6940#issuecomment-1221642349 https://api.github.com/repos/pydata/xarray/issues/6940 1221642349 IC_kwDOAMm_X85I0Mht 6628425 2022-08-21T23:24:06Z 2022-08-21T23:24:06Z MEMBER

Ah, this still didn't quite work for older dask versions:

``` ====================================================================================================== FAILURES ======================================================================================================= ___________________________________________________________________________________________ test_cftime_datetime_mean[True] ___________________________________________________________________________________________ dask = True @requires_cftime @pytest.mark.parametrize("dask", [False, True]) def test_cftime_datetime_mean(dask): if dask and not has_dask: pytest.skip("requires dask") times = cftime_range("2000", periods=4) da = DataArray(times, dims=["time"]) da_2d = DataArray(times.values.reshape(2, 2)) if dask: da = da.chunk({"time": 2}) da_2d = da_2d.chunk({"dim_0": 2}) expected = da.isel(time=0) # one compute needed to check the array contains cftime datetimes with raise_if_dask_computes(max_computes=1): > result = da.isel(time=0).mean() /Users/spencer/software/xarray/xarray/tests/test_duck_array_ops.py:342: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /Users/spencer/software/xarray/xarray/core/_reductions.py:1478: in mean return self.reduce( /Users/spencer/software/xarray/xarray/core/dataarray.py:2930: in reduce var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs) /Users/spencer/software/xarray/xarray/core/variable.py:1854: in reduce data = func(self.data, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ array = dask.array<getitem, shape=(), dtype=object, chunksize=(), chunktype=numpy.ndarray>, axis = None, skipna = None, kwargs = {} _contains_cftime_datetimes = <function _contains_cftime_datetimes at 0x7fcdd91ce3a0>, offset = dask.array<where, shape=(), dtype=object, chunksize=(), chunktype=numpy.ndarray> timedeltas = dask.array<multiply, shape=(), dtype=float64, chunksize=(), chunktype=numpy.ndarray>, mean_timedeltas = dask.array<mean_agg-aggregate, shape=(), dtype=float64, chunksize=(), chunktype=numpy.ndarray> def mean(array, axis=None, skipna=None, **kwargs): """inhouse mean that can handle np.datetime64 or cftime.datetime dtypes""" from .common import _contains_cftime_datetimes array = asarray(array) if array.dtype.kind in "Mm": offset = _datetime_nanmin(array) # xarray always uses np.datetime64[ns] for np.datetime64 data dtype = "timedelta64[ns]" return ( _mean( datetime_to_numeric(array, offset), axis=axis, skipna=skipna, **kwargs ).astype(dtype) + offset ) elif _contains_cftime_datetimes(array): offset = min(array) timedeltas = datetime_to_numeric(array, offset, datetime_unit="us") mean_timedeltas = _mean(timedeltas, axis=axis, skipna=skipna, **kwargs) > return _to_pytimedelta(mean_timedeltas, unit="us") + offset E TypeError: unsupported operand type(s) for +: 'Array' and 'Array' /Users/spencer/software/xarray/xarray/core/duck_array_ops.py:573: TypeError ```

This appears to be the commit that fixed this issue in dask, meaning it should be fixed as of dask version 2021.07.0: ``` git bisect broken 626cc724ffa1d14cd74f48ff4f21ef443d832afa is the first fixed commit commit 626cc724ffa1d14cd74f48ff4f21ef443d832afa Author: Julia Signell jsignell@gmail.com Date: Tue Jun 29 11:50:36 2021 -0400

Allow mixing dask and numpy arrays in @guvectorize (#6863)

dask/array/core.py | 7 ++++++- dask/array/tests/test_gufunc.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1345573285
Powered by Datasette · Queries took 0.795ms · About: xarray-datasette