Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8e73d52

Browse files
committedNov 14, 2024
Redo calendar fixtures
1 parent bd21b48 commit 8e73d52

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed
 

‎xarray/tests/__init__.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import xarray.testing
1818
from xarray import Dataset
19+
from xarray.coding.times import _STANDARD_CALENDARS as _STANDARD_CALENDARS_UNSORTED
1920
from xarray.core.duck_array_ops import allclose_or_equiv # noqa: F401
2021
from xarray.core.extension_array import PandasExtensionArray
2122
from xarray.core.options import set_options
@@ -353,12 +354,33 @@ def create_test_data(
353354

354355

355356
_CFTIME_CALENDARS = [
356-
"365_day",
357-
"360_day",
358-
"julian",
359-
"all_leap",
360-
"366_day",
361-
"gregorian",
362-
"proleptic_gregorian",
363-
"standard",
357+
pytest.param(
358+
cal, marks=pytest.mark.skipif(not has_cftime, reason="requires cftime")
359+
)
360+
for cal in [
361+
"365_day",
362+
"360_day",
363+
"julian",
364+
"all_leap",
365+
"366_day",
366+
"gregorian",
367+
"proleptic_gregorian",
368+
"standard",
369+
]
370+
]
371+
372+
_NON_STANDARD_CALENDARS = [
373+
pytest.param(
374+
cal, marks=pytest.mark.skipif(not has_cftime, reason="requires cftime")
375+
)
376+
for cal in [
377+
"noleap",
378+
"365_day",
379+
"360_day",
380+
"julian",
381+
"all_leap",
382+
"366_day",
383+
]
364384
]
385+
_STANDARD_CALENDARS = sorted(_STANDARD_CALENDARS_UNSORTED)
386+
_ALL_CALENDARS = _STANDARD_CALENDARS + _NON_STANDARD_CALENDARS

‎xarray/tests/test_accessor_dt.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import xarray as xr
88
from xarray.tests import (
9+
_CFTIME_CALENDARS,
910
assert_allclose,
1011
assert_array_equal,
1112
assert_chunks_equal,
@@ -390,15 +391,6 @@ def test_dask_accessor_method(self, method, parameters) -> None:
390391
assert_equal(actual.compute(), expected.compute())
391392

392393

393-
_CFTIME_CALENDARS = [
394-
"365_day",
395-
"360_day",
396-
"julian",
397-
"all_leap",
398-
"366_day",
399-
"gregorian",
400-
"proleptic_gregorian",
401-
]
402394
_NT = 100
403395

404396

‎xarray/tests/test_coding_times.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
date_range,
2020
decode_cf,
2121
)
22-
from xarray.coding.times import _STANDARD_CALENDARS as _STANDARD_CALENDARS_UNSORTED
2322
from xarray.coding.times import (
2423
CFDatetimeCoder,
2524
_encode_datetime_with_cftime,
@@ -42,6 +41,9 @@
4241
from xarray.core.utils import is_duck_dask_array
4342
from xarray.testing import assert_equal, assert_identical
4443
from xarray.tests import (
44+
_ALL_CALENDARS,
45+
_NON_STANDARD_CALENDARS,
46+
_STANDARD_CALENDARS,
4547
FirstElementAccessibleArray,
4648
arm_xfail,
4749
assert_array_equal,
@@ -53,17 +55,6 @@
5355
requires_dask,
5456
)
5557

56-
_NON_STANDARD_CALENDARS_SET = {
57-
"noleap",
58-
"365_day",
59-
"360_day",
60-
"julian",
61-
"all_leap",
62-
"366_day",
63-
}
64-
_STANDARD_CALENDARS = sorted(_STANDARD_CALENDARS_UNSORTED)
65-
_ALL_CALENDARS = sorted(_NON_STANDARD_CALENDARS_SET.union(_STANDARD_CALENDARS))
66-
_NON_STANDARD_CALENDARS = sorted(_NON_STANDARD_CALENDARS_SET)
6758
_CF_DATETIME_NUM_DATES_UNITS = [
6859
(np.arange(10), "days since 2000-01-01"),
6960
(np.arange(10).astype("float64"), "days since 2000-01-01"),

0 commit comments

Comments
 (0)
Please sign in to comment.