@@ -40,7 +40,7 @@ def generate_slice_indices(kind: int):
40
40
case 2 :
41
41
# positive continuous range
42
42
s = slice (1 , 5 , None )
43
- indices = list ( range ( 1 , 5 ))
43
+ indices = [ 1 , 2 , 3 , 4 ]
44
44
45
45
case 3 :
46
46
# positive stepped range
@@ -114,7 +114,9 @@ def generate_slice_indices(kind: int):
114
114
115
115
others = [i for i in a if i not in indices ]
116
116
117
- return {"slice" : s , "indices" : indices , "others" : others }
117
+ offset , size = (min (indices ), np .ptp (indices ) + 1 )
118
+
119
+ return {"slice" : s , "indices" : indices , "others" : others , "offset" : offset , "size" : size }
118
120
119
121
120
122
def make_colors_buffer () -> ColorFeature :
@@ -205,14 +207,29 @@ def test_slice(color_input, slice_method: dict):
205
207
# slicing only first dim
206
208
colors = make_colors_buffer ()
207
209
210
+ # TODO: placeholder until I make a testing figure where we draw frames only on call
211
+ colors .buffer ._gfx_pending_uploads .clear ()
212
+
208
213
s = slice_method ["slice" ]
209
214
indices = slice_method ["indices" ]
215
+ offset = slice_method ["offset" ]
216
+ size = slice_method ["size" ]
210
217
others = slice_method ["others" ]
211
218
212
219
colors [s ] = color_input
213
220
truth = np .repeat ([pygfx .Color (color_input )], repeats = len (indices ), axis = 0 )
214
221
# check that correct indices are modified
215
222
npt .assert_almost_equal (colors [s ], truth )
223
+
224
+ upload_offset , upload_size = colors .buffer ._gfx_pending_uploads [- 1 ]
225
+ # sometimes when slicing with step, it will over-estimate offset
226
+ # but it overestimates to upload 1 extra point so it's fine
227
+ assert (upload_offset == offset ) or (upload_offset == offset - 1 )
228
+
229
+ # sometimes when slicing with step, it will over-estimate size
230
+ # but it overestimates to upload 1 extra point so it's fine
231
+ assert (upload_size == size ) or (upload_size == size + 1 )
232
+
216
233
# check that others are not touched
217
234
others_truth = np .repeat ([[1. , 1. , 1. , 1. ]], repeats = len (others ), axis = 0 )
218
235
npt .assert_almost_equal (colors [others ], others_truth )
0 commit comments