From 0ad7b94e2159e5ad9083c69f3a36d078b56b4c2e Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Wed, 1 Feb 2017 13:01:52 -0500 Subject: [PATCH] COMPAT: xarray 0.8.2 test compat w.r.t. CategoricalIndex indempotency closes #15282 --- ci/install_travis.sh | 2 +- ci/requirements-2.7.run | 2 +- ci/requirements-3.5.pip | 1 + ci/requirements-3.5.run | 1 - pandas/tests/test_generic.py | 19 +++++++++++-------- 5 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 ci/requirements-3.5.pip diff --git a/ci/install_travis.sh b/ci/install_travis.sh index ded428c677f17..52b52d787aade 100755 --- a/ci/install_travis.sh +++ b/ci/install_travis.sh @@ -143,7 +143,7 @@ else echo "[pip installs]" REQ="ci/requirements-${PYTHON_VERSION}${JOB_TAG}.pip" if [ -e ${REQ} ]; then - pip install --upgrade -r $REQ + pip install -r $REQ fi # may have addtl installation instructions for this build diff --git a/ci/requirements-2.7.run b/ci/requirements-2.7.run index 2bfb8a3777fdf..b5fc919297c76 100644 --- a/ci/requirements-2.7.run +++ b/ci/requirements-2.7.run @@ -20,4 +20,4 @@ html5lib=1.0b2 beautiful-soup=4.2.1 statsmodels jinja2=2.8 -xarray +xarray=0.8.0 diff --git a/ci/requirements-3.5.pip b/ci/requirements-3.5.pip new file mode 100644 index 0000000000000..0d9e44cf39fa4 --- /dev/null +++ b/ci/requirements-3.5.pip @@ -0,0 +1 @@ +xarray==0.9.1 diff --git a/ci/requirements-3.5.run b/ci/requirements-3.5.run index e15ca6079b4fe..ef354195c8f23 100644 --- a/ci/requirements-3.5.run +++ b/ci/requirements-3.5.run @@ -16,6 +16,5 @@ bottleneck sqlalchemy pymysql psycopg2 -xarray s3fs beautifulsoup4 diff --git a/pandas/tests/test_generic.py b/pandas/tests/test_generic.py index f7b7ae8c66382..0ca8ba47b8a8f 100644 --- a/pandas/tests/test_generic.py +++ b/pandas/tests/test_generic.py @@ -7,6 +7,7 @@ from numpy import nan import pandas as pd +from distutils.version import LooseVersion from pandas.types.common import is_scalar from pandas import (Index, Series, DataFrame, Panel, isnull, date_range, period_range, Panel4D) @@ -870,6 +871,7 @@ def test_describe_none(self): def test_to_xarray(self): tm._skip_if_no_xarray() + import xarray from xarray import DataArray s = Series([]) @@ -895,15 +897,16 @@ def testit(index, check_index_type=True, check_categorical=True): check_index_type=check_index_type, check_categorical=check_categorical) - for index in [tm.makeFloatIndex, tm.makeIntIndex, - tm.makeStringIndex, tm.makeUnicodeIndex, - tm.makeDateIndex, tm.makePeriodIndex, - tm.makeTimedeltaIndex]: - testit(index) + l = [tm.makeFloatIndex, tm.makeIntIndex, + tm.makeStringIndex, tm.makeUnicodeIndex, + tm.makeDateIndex, tm.makePeriodIndex, + tm.makeTimedeltaIndex] + + if LooseVersion(xarray.__version__) >= '0.8.0': + l.append(tm.makeCategoricalIndex) - # not idempotent - testit(tm.makeCategoricalIndex, check_index_type=False, - check_categorical=False) + for index in l: + testit(index) s = Series(range(6)) s.index.name = 'foo'