From b9d90c3455822888156467a298987373073e27fd Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Mon, 23 Mar 2020 20:47:24 +0200 Subject: [PATCH 1/3] CLN: xarray tests --- pandas/tests/generic/test_to_xarray.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/pandas/tests/generic/test_to_xarray.py b/pandas/tests/generic/test_to_xarray.py index 250fe950a05fc..b6abdf09a7f62 100644 --- a/pandas/tests/generic/test_to_xarray.py +++ b/pandas/tests/generic/test_to_xarray.py @@ -1,5 +1,3 @@ -from distutils.version import LooseVersion - import numpy as np import pytest @@ -9,21 +7,9 @@ from pandas import DataFrame, Series import pandas._testing as tm -try: - import xarray - - _XARRAY_INSTALLED = True -except ImportError: - _XARRAY_INSTALLED = False - class TestDataFrameToXArray: - @pytest.mark.skipif( - not _XARRAY_INSTALLED - or _XARRAY_INSTALLED - and LooseVersion(xarray.__version__) < LooseVersion("0.10.0"), - reason="xarray >= 0.10.0 required", - ) + @td.skip_if_no("xarray", "0.10.0") def test_to_xarray_index_types(self, indices): if isinstance(indices, pd.MultiIndex): pytest.skip("MultiIndex is tested separately") @@ -106,12 +92,7 @@ def test_to_xarray(self): class TestSeriesToXArray: - @pytest.mark.skipif( - not _XARRAY_INSTALLED - or _XARRAY_INSTALLED - and LooseVersion(xarray.__version__) < LooseVersion("0.10.0"), - reason="xarray >= 0.10.0 required", - ) + @td.skip_if_no("xarray", "0.10.0") def test_to_xarray_index_types(self, indices): if isinstance(indices, pd.MultiIndex): pytest.skip("MultiIndex is tested separately") From 682e99bfc592944cc02cf54e78ce0039c567c7c5 Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Mon, 23 Mar 2020 20:56:55 +0200 Subject: [PATCH 2/3] Supress warning `DeprecationWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.` --- pandas/tests/generic/test_to_xarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/generic/test_to_xarray.py b/pandas/tests/generic/test_to_xarray.py index b6abdf09a7f62..655032426400f 100644 --- a/pandas/tests/generic/test_to_xarray.py +++ b/pandas/tests/generic/test_to_xarray.py @@ -99,7 +99,7 @@ def test_to_xarray_index_types(self, indices): from xarray import DataArray - s = Series(range(len(indices)), index=indices) + s = Series(range(len(indices)), index=indices, dtype="float64") s.index.name = "foo" result = s.to_xarray() repr(result) From 76107751b25e0734ef7c77c231738d6ea5946a4b Mon Sep 17 00:00:00 2001 From: MomIsBestFriend <> Date: Tue, 24 Mar 2020 15:02:16 +0200 Subject: [PATCH 3/3] Revert "Supress warning" This reverts commit 682e99bfc592944cc02cf54e78ce0039c567c7c5. --- pandas/tests/generic/test_to_xarray.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/generic/test_to_xarray.py b/pandas/tests/generic/test_to_xarray.py index 655032426400f..b6abdf09a7f62 100644 --- a/pandas/tests/generic/test_to_xarray.py +++ b/pandas/tests/generic/test_to_xarray.py @@ -99,7 +99,7 @@ def test_to_xarray_index_types(self, indices): from xarray import DataArray - s = Series(range(len(indices)), index=indices, dtype="float64") + s = Series(range(len(indices)), index=indices) s.index.name = "foo" result = s.to_xarray() repr(result)