From 49ee573fac77dc5322e30a7eb12af6e8e0a507ac Mon Sep 17 00:00:00 2001 From: dcherian Date: Wed, 11 Sep 2019 09:23:39 -0600 Subject: [PATCH 1/6] ignore h5py 2.10.0 warnings and fix invalid_netcdf warning test. --- xarray/tests/test_backends.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index a5c42fd368c..aea8b3aa18d 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -2163,6 +2163,7 @@ def test_encoding_unlimited_dims(self): @requires_h5netcdf @requires_netCDF4 +@pytest.mark.filterwarnings("ignore:use make_scale(name) instead") class TestH5NetCDFData(NetCDF4Base): engine = "h5netcdf" @@ -2171,10 +2172,11 @@ def create_store(self): with create_tmp_file() as tmp_file: yield backends.H5NetCDFStore(tmp_file, "w") + # TODO: Reduce num_warns by 1 when h5netcdf is updated to not issue the make_scale warning @pytest.mark.filterwarnings("ignore:complex dtypes are supported by h5py") @pytest.mark.parametrize( "invalid_netcdf, warns, num_warns", - [(None, FutureWarning, 1), (False, FutureWarning, 1), (True, None, 0)], + [(None, FutureWarning, 2), (False, FutureWarning, 2), (True, None, 1)], ) def test_complex(self, invalid_netcdf, warns, num_warns): expected = Dataset({"x": ("y", np.ones(5) + 1j * np.ones(5))}) @@ -2451,6 +2453,7 @@ def skip_if_not_engine(engine): @requires_dask +@pytest.mark.filterwarnings("ignore:use make_scale(name) instead") def test_open_mfdataset_manyfiles( readengine, nfiles, parallel, chunks, file_cache_maxsize ): From ce4596dd2add49e579f5dfb341a92c628abc01bf Mon Sep 17 00:00:00 2001 From: dcherian Date: Thu, 12 Sep 2019 07:58:20 -0600 Subject: [PATCH 2/6] Better fix. --- xarray/tests/test_backends.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index aea8b3aa18d..07907b80b51 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -2176,15 +2176,22 @@ def create_store(self): @pytest.mark.filterwarnings("ignore:complex dtypes are supported by h5py") @pytest.mark.parametrize( "invalid_netcdf, warns, num_warns", - [(None, FutureWarning, 2), (False, FutureWarning, 2), (True, None, 1)], + [(None, FutureWarning, 1), (False, FutureWarning, 1), (True, None, 0)], ) - def test_complex(self, invalid_netcdf, warns, num_warns): + def test_complex(self, invalid_netcdf, warntype, num_warns): expected = Dataset({"x": ("y", np.ones(5) + 1j * np.ones(5))}) save_kwargs = {"invalid_netcdf": invalid_netcdf} - with pytest.warns(warns) as record: + with pytest.warns(warntype) as record: with self.roundtrip(expected, save_kwargs=save_kwargs) as actual: assert_equal(expected, actual) - assert len(record) == num_warns + + recorded_num_warns = 0 + if warntype: + for warning in record: + if issubclass(warning.category, warntype): + recorded_num_warns += 1 + + assert recorded_num_warns == num_warns def test_cross_engine_read_write_netcdf4(self): # Drop dim3, because its labels include strings. These appear to be From e82decc50873e6b412b8f4551902bed2b5242c52 Mon Sep 17 00:00:00 2001 From: dcherian Date: Thu, 12 Sep 2019 09:03:37 -0600 Subject: [PATCH 3/6] fix fix. --- xarray/tests/test_backends.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 07907b80b51..8bb621790e4 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -2175,7 +2175,7 @@ def create_store(self): # TODO: Reduce num_warns by 1 when h5netcdf is updated to not issue the make_scale warning @pytest.mark.filterwarnings("ignore:complex dtypes are supported by h5py") @pytest.mark.parametrize( - "invalid_netcdf, warns, num_warns", + "invalid_netcdf, warntype, num_warns", [(None, FutureWarning, 1), (False, FutureWarning, 1), (True, None, 0)], ) def test_complex(self, invalid_netcdf, warntype, num_warns): @@ -2188,7 +2188,9 @@ def test_complex(self, invalid_netcdf, warntype, num_warns): recorded_num_warns = 0 if warntype: for warning in record: - if issubclass(warning.category, warntype): + if issubclass(warning.category, warntype) and ( + "complex dtypes" in str(warning.message) + ): recorded_num_warns += 1 assert recorded_num_warns == num_warns From c2c10dadb842762d59bc2af1d273646b3ca2f643 Mon Sep 17 00:00:00 2001 From: dcherian Date: Thu, 12 Sep 2019 09:05:11 -0600 Subject: [PATCH 4/6] remove comment. --- xarray/tests/test_backends.py | 1 - 1 file changed, 1 deletion(-) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 8bb621790e4..f6254b32f4f 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -2172,7 +2172,6 @@ def create_store(self): with create_tmp_file() as tmp_file: yield backends.H5NetCDFStore(tmp_file, "w") - # TODO: Reduce num_warns by 1 when h5netcdf is updated to not issue the make_scale warning @pytest.mark.filterwarnings("ignore:complex dtypes are supported by h5py") @pytest.mark.parametrize( "invalid_netcdf, warntype, num_warns", From 14ae0b1153f56144c7a90966512f0a156355cf25 Mon Sep 17 00:00:00 2001 From: dcherian Date: Thu, 12 Sep 2019 09:09:55 -0600 Subject: [PATCH 5/6] Add docs. --- doc/computation.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/computation.rst b/doc/computation.rst index 3d10774bcac..708388c4e8b 100644 --- a/doc/computation.rst +++ b/doc/computation.rst @@ -94,7 +94,8 @@ for filling missing values via 1D interpolation. Note that xarray slightly diverges from the pandas ``interpolate`` syntax by providing the ``use_coordinate`` keyword which facilitates a clear specification -of which values to use as the index in the interpolation. +of which values to use as the index in the interpolation. xarray also provides the ``maxgap`` keyword argument to limit the interpolation to data gaps of length ``maxgap`` or smaller. See +:py:meth:`~xarray.DataArray.interpolate_na` for more. Aggregation =========== From fd3161834d4c6a1107c5de7feaec599625fb8969 Mon Sep 17 00:00:00 2001 From: dcherian Date: Thu, 12 Sep 2019 09:10:16 -0600 Subject: [PATCH 6/6] Revert "Add docs." This reverts commit 14ae0b1153f56144c7a90966512f0a156355cf25. --- doc/computation.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/computation.rst b/doc/computation.rst index 708388c4e8b..3d10774bcac 100644 --- a/doc/computation.rst +++ b/doc/computation.rst @@ -94,8 +94,7 @@ for filling missing values via 1D interpolation. Note that xarray slightly diverges from the pandas ``interpolate`` syntax by providing the ``use_coordinate`` keyword which facilitates a clear specification -of which values to use as the index in the interpolation. xarray also provides the ``maxgap`` keyword argument to limit the interpolation to data gaps of length ``maxgap`` or smaller. See -:py:meth:`~xarray.DataArray.interpolate_na` for more. +of which values to use as the index in the interpolation. Aggregation ===========