@@ -1141,29 +1141,28 @@ def test_chunks_does_not_load_data(self) -> None:
1141
1141
[(True , "standard" ), (False , "standard" ), (True , "noleap" ), (True , "360_day" )],
1142
1142
)
1143
1143
def test_chunk_by_season_resampler (self , use_cftime : bool , calendar : str ) -> None :
1144
- # With 2 years of data starting Jan 1, we get 9 seasonal chunks:
1145
- # partial DJF (Jan-Feb), MAM, JJA, SON, DJF, MAM, JJA, SON, partial DJF (Dec)
1146
1144
ds = xr .Dataset (
1147
1145
{"foo" : (("x" , "time" ), np .ones ((10 , 365 * 2 )))},
1148
1146
coords = {
1149
1147
"x" : np .arange (10 ),
1150
1148
"time" : pd .date_range ("2000-01-01" , periods = 365 * 2 ),
1151
1149
},
1152
1150
)
1153
- rechunked = ds .chunk ({"x" : 2 , "time" : SeasonResampler ()})
1151
+
1152
+ # Standard seasons
1153
+ rechunked = ds .chunk (
1154
+ {"x" : 2 , "time" : SeasonResampler (["DJF" , "MAM" , "JJA" , "SON" ])}
1155
+ )
1154
1156
assert len (rechunked .chunksizes ["time" ]) == 9
1155
1157
assert rechunked .chunksizes ["x" ] == (2 ,) * 5
1156
- # Write out the actual chunks tuple for clarity
1157
1158
assert rechunked .chunksizes ["time" ] == (31 , 92 , 92 , 92 , 31 , 92 , 92 , 92 , 31 )
1158
1159
1159
- # Test custom seasons
1160
+ # Custom seasons
1160
1161
rechunked = ds .chunk (
1161
1162
{"x" : 2 , "time" : SeasonResampler (["DJFM" , "AM" , "JJA" , "SON" ])}
1162
1163
)
1163
- # Custom seasons also produce boundary chunks
1164
1164
assert len (rechunked .chunksizes ["time" ]) == 9
1165
1165
assert rechunked .chunksizes ["x" ] == (2 ,) * 5
1166
- # Write out the actual chunks tuple for clarity
1167
1166
assert rechunked .chunksizes ["time" ] == (120 , 61 , 92 , 92 , 120 , 61 , 92 , 92 , 120 )
1168
1167
"""Test chunking using SeasonResampler."""
1169
1168
import dask .array
0 commit comments