home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 1098241812

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1098241812 I_kwDOAMm_X85BddcU 6149 [Bug]: `numpy` `DeprecationWarning` with `DType` and `xr.testing.assert_all_close()` + Dask 25624127 closed 0     4 2022-01-10T18:34:27Z 2023-09-13T20:06:59Z 2023-09-13T20:06:58Z CONTRIBUTOR      

What happened?

A numpy DeprecationWarning regarding DType is being outputted when using xr.testing.assert_all_close() to compare two chunked Datasets. This does warning does not appear with two non-chunked datasets.

What did you expect to happen?

The warning should not appear.

Minimal Complete Verifiable Example

```python class TestTemporalAvg: class TestTimeseries: @pytest.fixture(autouse=True) def setup(self): self.ds: xr.Dataset = generate_dataset(cf_compliant=True, has_bounds=True)

    # No warning with this test
    def test_weighted_annual_avg(self):
        ds = self.ds.copy()

        result = ds.temporal.temporal_avg("timeseries", "year", data_var="ts")
        expected = ds.copy()
        expected["ts"] = xr.DataArray(
            name="ts",
            data=np.ones((2, 4, 4)),
            coords={
                "lat": self.ds.lat,
                "lon": self.ds.lon,
                "year": pd.MultiIndex.from_tuples(
                    [(2000,), (2001,)],
                ),
            },
            dims=["year", "lat", "lon"],
            attrs={
                "operation": "temporal_avg",
                "mode": "timeseries",
                "freq": "year",
                "groupby": "year",
                "weighted": "True",
                "centered_time": "True",
            },
        )

        # For some reason, there is a floating point difference between both
        # for ts so we have to use floating point comparison
        xr.testing.assert_allclose(result, expected)
        assert result.ts.attrs == expected.ts.attrs

    # Warning with this test
    @requires_dask
    def test_weighted_annual_avg_with_chunking(self):
        ds = self.ds.copy().chunk({"time": 2})

        result = ds.temporal.temporal_avg("timeseries", "year", data_var="ts")
        expected = ds.copy()
        expected["ts"] = xr.DataArray(
            name="ts",
            data=np.ones((2, 4, 4)),
            coords={
                "lat": ds.lat,
                "lon": ds.lon,
                "year": pd.MultiIndex.from_tuples(
                    [(2000,), (2001,)],
                ),
            },
            dims=["year", "lat", "lon"],
            attrs={
                "operation": "temporal_avg",
                "mode": "timeseries",
                "freq": "year",
                "groupby": "year",
                "weighted": "True",
                "centered_time": "True",
            },
        )

        # For some reason, there is a floating point difference between both
        # for ts so we have to use floating point comparison
        xr.testing.assert_allclose(result, expected)
        assert result.ts.attrs == expected.ts.attrs

```

Relevant log output

python DeprecationWarning: The `dtype` and `signature` arguments to ufuncs only select the general DType and not details such as the byte order or time unit (with rare exceptions see release notes). To avoid this warning please use the scalar types `np.float64`, or string notation. In rare cases where the time unit was preserved, either cast the inputs or provide an output array. In the future NumPy may transition to allow providing `dtype=` to denote the outputs `dtype` as well. (Deprecated NumPy 1.21) return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS

commit: None python: 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:20:46) [GCC 9.4.0] python-bits: 64 OS: Linux OS-release: 3.10.0-1160.45.1.el7.x86_64 machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.1 libnetcdf: 4.8.1

xarray: 0.20.1 pandas: 1.3.4 numpy: 1.21.4 scipy: None netCDF4: 1.5.8 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.5.1.1 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2021.11.2 distributed: 2021.11.2 matplotlib: None cartopy: None seaborn: None numbagg: None fsspec: 2021.11.1 cupy: None pint: None sparse: None setuptools: 59.6.0 pip: 21.3.1 conda: None pytest: 6.2.5 IPython: 7.30.1 sphinx: 4.3.1

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6149/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  not_planned 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 0.616ms · About: xarray-datasette