Skip to content

Commit

Permalink
Re-enable tests xfailed in #3808 and fix new CFTimeIndex failures due…
Browse files Browse the repository at this point in the history
… to upstream changes (#3874)

* Re-enable tests xfailed in #3808

* Add _cache attribute to CFTimeIndex

* Temporarily install pandas master from GitHub instead of wheel

* Fix pandas url
  • Loading branch information
spencerkclark authored Mar 22, 2020
1 parent 6c19aab commit 2d0b85e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
4 changes: 2 additions & 2 deletions ci/azure/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ steps:
--upgrade \
matplotlib \
numpy \
pandas \
scipy
python -m pip install \
--no-deps \
Expand All @@ -30,7 +29,8 @@ steps:
git+https://github.com/Unidata/cftime \
git+https://github.com/mapbox/rasterio \
git+https://github.com/hgrecco/pint \
git+https://github.com/pydata/bottleneck
git+https://github.com/pydata/bottleneck \
git+https://github.com/pandas-dev/pandas
condition: eq(variables['UPSTREAM_DEV'], 'true')
displayName: Install upstream dev dependencies

Expand Down
1 change: 1 addition & 0 deletions xarray/coding/cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def __new__(cls, data, name=None):
result = object.__new__(cls)
result._data = np.array(data, dtype="O")
result.name = name
result._cache = {}
return result

def _partial_date_slice(self, resolution, parsed):
Expand Down
17 changes: 2 additions & 15 deletions xarray/tests/test_cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ def test_sel_date_scalar(da, date_type, index):
assert_identical(result, expected)


@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
@requires_cftime
def test_sel_date_distant_date(da, date_type, index):
expected = xr.DataArray(4).assign_coords(time=index[3])
Expand Down Expand Up @@ -513,20 +512,14 @@ def test_sel_date_scalar_backfill(da, date_type, index, sel_kwargs):
[
{"method": "pad", "tolerance": timedelta(days=20)},
{"method": "backfill", "tolerance": timedelta(days=20)},
pytest.param(
{"method": "nearest", "tolerance": timedelta(days=20)},
marks=pytest.mark.xfail(
reason="https://github.com/pydata/xarray/issues/3751"
),
),
{"method": "nearest", "tolerance": timedelta(days=20)},
],
)
def test_sel_date_scalar_tolerance_raises(da, date_type, sel_kwargs):
with pytest.raises(KeyError):
da.sel(time=date_type(1, 5, 1), **sel_kwargs)


@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
@requires_cftime
@pytest.mark.parametrize(
"sel_kwargs",
Expand Down Expand Up @@ -574,12 +567,7 @@ def test_sel_date_list_backfill(da, date_type, index, sel_kwargs):
[
{"method": "pad", "tolerance": timedelta(days=20)},
{"method": "backfill", "tolerance": timedelta(days=20)},
pytest.param(
{"method": "nearest", "tolerance": timedelta(days=20)},
marks=pytest.mark.xfail(
reason="https://github.com/pydata/xarray/issues/3751"
),
),
{"method": "nearest", "tolerance": timedelta(days=20)},
],
)
def test_sel_date_list_tolerance_raises(da, date_type, sel_kwargs):
Expand Down Expand Up @@ -614,7 +602,6 @@ def range_args(date_type):
]


@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
@requires_cftime
def test_indexing_in_series_getitem(series, index, scalar_args, range_args):
for arg in scalar_args:
Expand Down
4 changes: 0 additions & 4 deletions xarray/tests/test_interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,6 @@ def test_datetime_single_string():
assert_allclose(actual.drop_vars("time"), expected)


@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
@requires_cftime
@requires_scipy
def test_cftime():
Expand All @@ -613,7 +612,6 @@ def test_cftime_type_error():
da.interp(time=times_new)


@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
@requires_cftime
@requires_scipy
def test_cftime_list_of_strings():
Expand All @@ -635,7 +633,6 @@ def test_cftime_list_of_strings():
assert_allclose(actual, expected)


@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
@requires_cftime
@requires_scipy
def test_cftime_single_string():
Expand Down Expand Up @@ -697,7 +694,6 @@ def test_datetime_interp_noerror():
a.interp(x=xi, time=xi.time) # should not raise an error


@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
@requires_cftime
def test_3641():
times = xr.cftime_range("0001", periods=3, freq="500Y")
Expand Down

0 comments on commit 2d0b85e

Please sign in to comment.