@@ -56,13 +56,11 @@ def setup(self):
5656 "nanosecond" ,
5757 "week" ,
5858 "weekofyear" ,
59- "dayofweek" ,
60- "weekday" ,
61- "dayofyear" ,
59+ "day_of_week" ,
60+ "day_of_year" ,
6261 "quarter" ,
6362 "date" ,
6463 "time" ,
65- "daysinmonth" ,
6664 "days_in_month" ,
6765 "is_month_start" ,
6866 "is_month_end" ,
@@ -104,6 +102,21 @@ def test_field_access(self, field) -> None:
104102 assert expected .dtype == actual .dtype
105103 assert_identical (expected , actual )
106104
105+ @pytest .mark .parametrize (
106+ ("field" , "replacement" ),
107+ [
108+ ("daysinmonth" , "days_in_month" ),
109+ ("dayofweek" , "day_of_week" ),
110+ ("weekday" , "day_of_week" ),
111+ ("dayofyear" , "day_of_year" ),
112+ ],
113+ )
114+ def test_deprecated_field_access (self , field , replacement ) -> None :
115+ expected = getattr (self .data .time .dt , replacement )
116+ with pytest .warns (FutureWarning , match = f"{ field } .*{ replacement } " ):
117+ actual = getattr (self .data .time .dt , field )
118+ assert_identical (expected , actual )
119+
107120 def test_total_seconds (self ) -> None :
108121 # Subtract a value in the middle of the range to ensure that some values
109122 # are negative
@@ -177,9 +190,8 @@ def test_not_datetime_type(self) -> None:
177190 "nanosecond" ,
178191 "week" ,
179192 "weekofyear" ,
180- "dayofweek" ,
181- "weekday" ,
182- "dayofyear" ,
193+ "day_of_week" ,
194+ "day_of_year" ,
183195 "quarter" ,
184196 "date" ,
185197 "time" ,
@@ -441,7 +453,7 @@ def times_3d(times):
441453
442454@requires_cftime
443455@pytest .mark .parametrize (
444- "field" , ["year" , "month" , "day" , "hour" , "dayofyear " , "dayofweek " ]
456+ "field" , ["year" , "month" , "day" , "hour" , "day_of_year " , "day_of_week " ]
445457)
446458def test_field_access (data , field ) -> None :
447459 result = getattr (data .time .dt , field )
@@ -533,7 +545,7 @@ def test_cftime_strftime_access(data) -> None:
533545@requires_cftime
534546@requires_dask
535547@pytest .mark .parametrize (
536- "field" , ["year" , "month" , "day" , "hour" , "dayofyear " , "dayofweek " ]
548+ "field" , ["year" , "month" , "day" , "hour" , "day_of_year " , "day_of_week " ]
537549)
538550def test_dask_field_access_1d (data , field ) -> None :
539551 import dask .array as da
@@ -553,7 +565,7 @@ def test_dask_field_access_1d(data, field) -> None:
553565@requires_cftime
554566@requires_dask
555567@pytest .mark .parametrize (
556- "field" , ["year" , "month" , "day" , "hour" , "dayofyear " , "dayofweek " ]
568+ "field" , ["year" , "month" , "day" , "hour" , "day_of_year " , "day_of_week " ]
557569)
558570def test_dask_field_access (times_3d , data , field ) -> None :
559571 import dask .array as da
0 commit comments