1313@pytest .fixture
1414def create_dataset ():
1515 def _create_dataset (start_date , periods , freq , calendar = "gregorian" ):
16- dates = xr .cftime_range (
17- start_date , periods = periods , freq = freq , calendar = calendar
16+ dates = xr .date_range (
17+ start_date , periods = periods , freq = freq , calendar = calendar , use_cftime = True
1818 )
1919 return xr .Dataset ({"time" : dates })
2020
@@ -50,13 +50,13 @@ def test_check_daily_time_axis_missing_time_key(create_dataset):
5050# Test check_monthly_time_axis
5151@pytest .mark .parametrize ("calendar" , ["gregorian" , "noleap" , "360_day" ])
5252def test_check_monthly_time_axis_correct (create_dataset , calendar ):
53- ds = create_dataset ("2000-01-01" , 24 , "M " , calendar = calendar )
53+ ds = create_dataset ("2000-01-01" , 24 , "ME " , calendar = calendar )
5454 assert check_monthly_time_axis (ds ) is None
5555
5656
5757def test_check_monthly_time_axis_incorrect (create_dataset ):
5858 # Test with incorrect monthly sequence
59- ds = create_dataset ("2000-01-01" , 24 , "2M " )
59+ ds = create_dataset ("2000-01-01" , 24 , "2ME " )
6060 with pytest .raises (ValueError , match = "DATA ERROR: time is not correct!" ):
6161 check_monthly_time_axis (ds )
6262
@@ -68,7 +68,7 @@ def test_check_monthly_time_axis_non_datetime():
6868
6969
7070def test_check_monthly_time_axis_missing_time_key (create_dataset ):
71- ds = create_dataset ("2000-01-01" , 24 , "M " )
71+ ds = create_dataset ("2000-01-01" , 24 , "ME " )
7272 with pytest .raises (KeyError ):
7373 check_monthly_time_axis (ds , time_key = "non_existent_key" )
7474
0 commit comments