File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,12 @@ def test_get_regular_chunks():
1818 assert len (target ) == 6
1919 assert list (target [0 ]) == list (range (0 , 8 ))
2020 assert list (target [- 1 ]) == list (range (40 , 48 ))
21+
22+
23+ def test_get_regular_chunks_max_inclusive ():
24+ target = list (get_regular_chunks (4 , 44 , 1 ))
25+
26+ assert len (target ) == 41
27+ assert list (target [0 ]) == list (range (4 , 5 ))
28+ # The last chunk should include 44
29+ assert list (target [- 1 ]) == list (range (44 , 45 ))
Original file line number Diff line number Diff line change @@ -63,9 +63,10 @@ def get_chunks(arr, chunk_size):
6363 yield arr [i : i + chunk_size ]
6464
6565
66+ # min_z and max_z are both inclusive
6667def get_regular_chunks (min_z , max_z , chunk_size ):
6768 i = floor (min_z / chunk_size ) * chunk_size
68- while i < ceil (max_z / chunk_size ) * chunk_size :
69+ while i < ceil (( max_z + 1 ) / chunk_size ) * chunk_size :
6970 yield range (i , i + chunk_size )
7071 i += chunk_size
7172
You can’t perform that action at this time.
0 commit comments