@@ -581,7 +581,7 @@ def test_weighted_seasonal_averages_with_DJF_and_drop_incomplete_seasons(self):
581
581
result = ds .temporal .group_average (
582
582
"ts" ,
583
583
"season" ,
584
- season_config = {"dec_mode" : "DJF" , "drop_incomplete_djf " : True },
584
+ season_config = {"dec_mode" : "DJF" , "drop_incomplete_seasons " : True },
585
585
)
586
586
expected = ds .copy ()
587
587
# Drop the incomplete DJF seasons
@@ -619,7 +619,7 @@ def test_weighted_seasonal_averages_with_DJF_and_drop_incomplete_seasons(self):
619
619
"freq" : "season" ,
620
620
"weighted" : "True" ,
621
621
"dec_mode" : "DJF" ,
622
- "drop_incomplete_djf " : "True" ,
622
+ "drop_incomplete_seasons " : "True" ,
623
623
},
624
624
)
625
625
@@ -633,7 +633,7 @@ def test_weighted_seasonal_averages_with_DJF_without_dropping_incomplete_seasons
633
633
result = ds .temporal .group_average (
634
634
"ts" ,
635
635
"season" ,
636
- season_config = {"dec_mode" : "DJF" , "drop_incomplete_djf " : False },
636
+ season_config = {"dec_mode" : "DJF" , "drop_incomplete_seasons " : False },
637
637
)
638
638
expected = ds .copy ()
639
639
expected = expected .drop_dims ("time" )
@@ -670,7 +670,7 @@ def test_weighted_seasonal_averages_with_DJF_without_dropping_incomplete_seasons
670
670
"freq" : "season" ,
671
671
"weighted" : "True" ,
672
672
"dec_mode" : "DJF" ,
673
- "drop_incomplete_djf " : "False" ,
673
+ "drop_incomplete_seasons " : "False" ,
674
674
},
675
675
)
676
676
@@ -822,7 +822,7 @@ def test_weighted_custom_seasonal_averages(self):
822
822
823
823
assert result .identical (expected )
824
824
825
- def test_weighted_seasonal_averages_drops_incomplete_seasons (self ):
825
+ def test_weighted_custom_seasonal_averages_drops_incomplete_seasons (self ):
826
826
ds = self .ds .copy ()
827
827
ds ["time" ].values [:] = np .array (
828
828
[
@@ -835,28 +835,26 @@ def test_weighted_seasonal_averages_drops_incomplete_seasons(self):
835
835
dtype = "datetime64[ns]" ,
836
836
)
837
837
838
- custom_seasons = [
839
- ["Nov" , "Dec" , "Jan" , "Feb" , "Mar" ],
840
- ]
838
+ custom_seasons = [["Nov" , "Dec" ], ["Feb" , "Mar" , "Apr" ]]
841
839
842
840
result = ds .temporal .group_average (
843
841
"ts" ,
844
842
"season" ,
845
843
season_config = {
844
+ "drop_incomplete_seasons" : True ,
846
845
"custom_seasons" : custom_seasons ,
847
- # "drop_incomplete_seasons": True,
848
846
},
849
847
)
850
848
expected = ds .copy ()
851
849
expected = expected .drop_dims ("time" )
852
850
expected ["ts" ] = xr .DataArray (
853
851
name = "ts" ,
854
- data = np .array ([[[1.3933333 ]]]),
852
+ data = np .array ([[[1.5 ]]]),
855
853
coords = {
856
854
"lat" : expected .lat ,
857
855
"lon" : expected .lon ,
858
856
"time" : xr .DataArray (
859
- data = np .array ([cftime .datetime (2001 , 1 , 1 )], dtype = object ),
857
+ data = np .array ([cftime .datetime (2000 , 12 , 1 )], dtype = object ),
860
858
dims = ["time" ],
861
859
attrs = {
862
860
"axis" : "T" ,
@@ -872,13 +870,12 @@ def test_weighted_seasonal_averages_drops_incomplete_seasons(self):
872
870
"operation" : "temporal_avg" ,
873
871
"mode" : "group_average" ,
874
872
"freq" : "season" ,
875
- "custom_seasons" : ["NovDecJanFebMar " ],
873
+ "custom_seasons" : ["NovDec" , "FebMarApr " ],
876
874
"weighted" : "True" ,
877
875
},
878
876
)
879
877
880
- xr .testing .assert_allclose (result , expected )
881
- assert result .ts .attrs == expected .ts .attrs
878
+ assert result .identical (expected )
882
879
883
880
def test_weighted_custom_seasonal_averages_with_seasons_spanning_calendar_years (
884
881
self ,
@@ -1160,7 +1157,7 @@ def test_weighted_seasonal_climatology_with_DJF(self):
1160
1157
result = ds .temporal .climatology (
1161
1158
"ts" ,
1162
1159
"season" ,
1163
- season_config = {"dec_mode" : "DJF" , "drop_incomplete_djf " : True },
1160
+ season_config = {"dec_mode" : "DJF" , "drop_incomplete_seasons " : True },
1164
1161
)
1165
1162
1166
1163
expected = ds .copy ()
@@ -1202,7 +1199,7 @@ def test_weighted_seasonal_climatology_with_DJF(self):
1202
1199
"freq" : "season" ,
1203
1200
"weighted" : "True" ,
1204
1201
"dec_mode" : "DJF" ,
1205
- "drop_incomplete_djf " : "True" ,
1202
+ "drop_incomplete_seasons " : "True" ,
1206
1203
},
1207
1204
)
1208
1205
@@ -1215,7 +1212,7 @@ def test_chunked_weighted_seasonal_climatology_with_DJF(self):
1215
1212
result = ds .temporal .climatology (
1216
1213
"ts" ,
1217
1214
"season" ,
1218
- season_config = {"dec_mode" : "DJF" , "drop_incomplete_djf " : True },
1215
+ season_config = {"dec_mode" : "DJF" , "drop_incomplete_seasons " : True },
1219
1216
)
1220
1217
1221
1218
expected = ds .copy ()
@@ -1257,7 +1254,7 @@ def test_chunked_weighted_seasonal_climatology_with_DJF(self):
1257
1254
"freq" : "season" ,
1258
1255
"weighted" : "True" ,
1259
1256
"dec_mode" : "DJF" ,
1260
- "drop_incomplete_djf " : "True" ,
1257
+ "drop_incomplete_seasons " : "True" ,
1261
1258
},
1262
1259
)
1263
1260
@@ -1378,7 +1375,7 @@ def test_weighted_custom_seasonal_climatology(self):
1378
1375
assert result .identical (expected )
1379
1376
1380
1377
@pytest .mark .xfail
1381
- def test_weighted_custom_seasonal_climatology_with_seasons_spanning_calendar_years_and_drop_incomplete_seasons (
1378
+ def test_weighted_custom_seasonal_climatology_with_seasons_spanning_calendar_years (
1382
1379
self ,
1383
1380
):
1384
1381
ds = self .ds .copy ()
@@ -1836,7 +1833,7 @@ def test_weighted_seasonal_departures_with_DJF(self):
1836
1833
result = ds .temporal .departures (
1837
1834
"ts" ,
1838
1835
"season" ,
1839
- season_config = {"dec_mode" : "DJF" , "drop_incomplete_djf " : True },
1836
+ season_config = {"dec_mode" : "DJF" , "drop_incomplete_seasons " : True },
1840
1837
)
1841
1838
expected = ds .copy ()
1842
1839
expected ["ts" ] = xr .DataArray (
@@ -1853,7 +1850,7 @@ def test_weighted_seasonal_departures_with_DJF(self):
1853
1850
"freq" : "season" ,
1854
1851
"weighted" : "True" ,
1855
1852
"dec_mode" : "DJF" ,
1856
- "drop_incomplete_djf " : "True" ,
1853
+ "drop_incomplete_seasons " : "True" ,
1857
1854
},
1858
1855
)
1859
1856
@@ -1871,7 +1868,7 @@ def test_weighted_seasonal_departures_with_DJF_and_keep_weights(self):
1871
1868
"season" ,
1872
1869
weighted = True ,
1873
1870
keep_weights = True ,
1874
- season_config = {"dec_mode" : "DJF" , "drop_incomplete_djf " : True },
1871
+ season_config = {"dec_mode" : "DJF" , "drop_incomplete_seasons " : True },
1875
1872
)
1876
1873
expected = ds .copy ()
1877
1874
expected ["ts" ] = xr .DataArray (
@@ -1888,7 +1885,7 @@ def test_weighted_seasonal_departures_with_DJF_and_keep_weights(self):
1888
1885
"freq" : "season" ,
1889
1886
"weighted" : "True" ,
1890
1887
"dec_mode" : "DJF" ,
1891
- "drop_incomplete_djf " : "True" ,
1888
+ "drop_incomplete_seasons " : "True" ,
1892
1889
},
1893
1890
)
1894
1891
expected ["time_wts" ] = xr .DataArray (
@@ -1925,7 +1922,7 @@ def test_unweighted_seasonal_departures_with_DJF(self):
1925
1922
"ts" ,
1926
1923
"season" ,
1927
1924
weighted = False ,
1928
- season_config = {"dec_mode" : "DJF" , "drop_incomplete_djf " : True },
1925
+ season_config = {"dec_mode" : "DJF" , "drop_incomplete_seasons " : True },
1929
1926
)
1930
1927
expected = ds .copy ()
1931
1928
expected ["ts" ] = xr .DataArray (
@@ -1942,7 +1939,7 @@ def test_unweighted_seasonal_departures_with_DJF(self):
1942
1939
"freq" : "season" ,
1943
1940
"weighted" : "False" ,
1944
1941
"dec_mode" : "DJF" ,
1945
- "drop_incomplete_djf " : "True" ,
1942
+ "drop_incomplete_seasons " : "True" ,
1946
1943
},
1947
1944
)
1948
1945
@@ -3128,7 +3125,7 @@ def test_raises_error_with_incorrect_mode_arg(self):
3128
3125
weighted = True ,
3129
3126
season_config = {
3130
3127
"dec_mode" : "DJF" ,
3131
- "drop_incomplete_djf " : False ,
3128
+ "drop_incomplete_seasons " : False ,
3132
3129
"custom_seasons" : None ,
3133
3130
},
3134
3131
)
@@ -3144,7 +3141,7 @@ def test_raises_error_if_freq_arg_is_not_supported_by_operation(self):
3144
3141
weighted = True ,
3145
3142
season_config = {
3146
3143
"dec_mode" : "DJF" ,
3147
- "drop_incomplete_djf " : False ,
3144
+ "drop_incomplete_seasons " : False ,
3148
3145
"custom_seasons" : None ,
3149
3146
},
3150
3147
)
@@ -3156,7 +3153,7 @@ def test_raises_error_if_freq_arg_is_not_supported_by_operation(self):
3156
3153
weighted = True ,
3157
3154
season_config = {
3158
3155
"dec_mode" : "DJF" ,
3159
- "drop_incomplete_djf " : False ,
3156
+ "drop_incomplete_seasons " : False ,
3160
3157
"custom_seasons" : None ,
3161
3158
},
3162
3159
)
@@ -3168,7 +3165,7 @@ def test_raises_error_if_freq_arg_is_not_supported_by_operation(self):
3168
3165
weighted = True ,
3169
3166
season_config = {
3170
3167
"dec_mode" : "DJF" ,
3171
- "drop_incomplete_djf " : False ,
3168
+ "drop_incomplete_seasons " : False ,
3172
3169
"custom_seasons" : None ,
3173
3170
},
3174
3171
)
@@ -3194,7 +3191,7 @@ def test_raises_error_if_december_mode_is_not_supported(self):
3194
3191
weighted = True ,
3195
3192
season_config = {
3196
3193
"dec_mode" : "unsupported" ,
3197
- "drop_incomplete_djf " : False ,
3194
+ "drop_incomplete_seasons " : False ,
3198
3195
"custom_seasons" : None ,
3199
3196
},
3200
3197
)
0 commit comments