Skip to content

Commit

Permalink
MRC -- Selecting with string for cftime
Browse files Browse the repository at this point in the history
See discussion in pydata#9138

This commit and pull request mostly serves as a staging group for a
potential fix.

Test with:

```
pytest xarray/tests/test_cftimeindex.py::test_cftime_noleap_with_str
```
  • Loading branch information
hmaarrfk committed Jun 29, 2024
1 parent 42ed6d3 commit 337532c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions xarray/tests/test_cftimeindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,22 @@ def test_cftimeindex_calendar_property(calendar, expected):
assert index.calendar == expected


@requires_cftime
def test_cftime_noleap_with_str():
# https://github.com/pydata/xarray/issues/9138
time = pd.date_range("2000-01-01", "2006-01-01", freq="D")
temperature = np.ones(len(time))
da = xr.DataArray(
data=temperature,
dims=["time"],
coords=dict(
time=time,
),
)
da_noleap = da.convert_calendar("noleap")
da_noleap.sel(time=slice("2001", "2002"))


@requires_cftime
def test_empty_cftimeindex_calendar_property():
index = CFTimeIndex([])
Expand Down

0 comments on commit 337532c

Please sign in to comment.