Skip to content

Commit 2d0b85e

Browse files
Re-enable tests xfailed in #3808 and fix new CFTimeIndex failures due 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
1 parent 6c19aab commit 2d0b85e

File tree

4 files changed

+5
-21
lines changed

4 files changed

+5
-21
lines changed

ci/azure/install.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ steps:
1919
--upgrade \
2020
matplotlib \
2121
numpy \
22-
pandas \
2322
scipy
2423
python -m pip install \
2524
--no-deps \
@@ -30,7 +29,8 @@ steps:
3029
git+https://github.com/Unidata/cftime \
3130
git+https://github.com/mapbox/rasterio \
3231
git+https://github.com/hgrecco/pint \
33-
git+https://github.com/pydata/bottleneck
32+
git+https://github.com/pydata/bottleneck \
33+
git+https://github.com/pandas-dev/pandas
3434
condition: eq(variables['UPSTREAM_DEV'], 'true')
3535
displayName: Install upstream dev dependencies
3636

xarray/coding/cftimeindex.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def __new__(cls, data, name=None):
253253
result = object.__new__(cls)
254254
result._data = np.array(data, dtype="O")
255255
result.name = name
256+
result._cache = {}
256257
return result
257258

258259
def _partial_date_slice(self, resolution, parsed):

xarray/tests/test_cftimeindex.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ def test_sel_date_scalar(da, date_type, index):
450450
assert_identical(result, expected)
451451

452452

453-
@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
454453
@requires_cftime
455454
def test_sel_date_distant_date(da, date_type, index):
456455
expected = xr.DataArray(4).assign_coords(time=index[3])
@@ -513,20 +512,14 @@ def test_sel_date_scalar_backfill(da, date_type, index, sel_kwargs):
513512
[
514513
{"method": "pad", "tolerance": timedelta(days=20)},
515514
{"method": "backfill", "tolerance": timedelta(days=20)},
516-
pytest.param(
517-
{"method": "nearest", "tolerance": timedelta(days=20)},
518-
marks=pytest.mark.xfail(
519-
reason="https://github.com/pydata/xarray/issues/3751"
520-
),
521-
),
515+
{"method": "nearest", "tolerance": timedelta(days=20)},
522516
],
523517
)
524518
def test_sel_date_scalar_tolerance_raises(da, date_type, sel_kwargs):
525519
with pytest.raises(KeyError):
526520
da.sel(time=date_type(1, 5, 1), **sel_kwargs)
527521

528522

529-
@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
530523
@requires_cftime
531524
@pytest.mark.parametrize(
532525
"sel_kwargs",
@@ -574,12 +567,7 @@ def test_sel_date_list_backfill(da, date_type, index, sel_kwargs):
574567
[
575568
{"method": "pad", "tolerance": timedelta(days=20)},
576569
{"method": "backfill", "tolerance": timedelta(days=20)},
577-
pytest.param(
578-
{"method": "nearest", "tolerance": timedelta(days=20)},
579-
marks=pytest.mark.xfail(
580-
reason="https://github.com/pydata/xarray/issues/3751"
581-
),
582-
),
570+
{"method": "nearest", "tolerance": timedelta(days=20)},
583571
],
584572
)
585573
def test_sel_date_list_tolerance_raises(da, date_type, sel_kwargs):
@@ -614,7 +602,6 @@ def range_args(date_type):
614602
]
615603

616604

617-
@pytest.mark.xfail(reason="https://github.com/pydata/xarray/issues/3751")
618605
@requires_cftime
619606
def test_indexing_in_series_getitem(series, index, scalar_args, range_args):
620607
for arg in scalar_args:

xarray/tests/test_interp.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ def test_datetime_single_string():
586586
assert_allclose(actual.drop_vars("time"), expected)
587587

588588

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

615614

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

637635

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

699696

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

0 commit comments

Comments
 (0)