File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -455,18 +455,19 @@ def subsample_array(
455455 np.ndarray
456456 subsample of the input array
457457 """
458- if np .prod (arr .shape ) <= max_size :
458+ full_shape = np .array (arr .shape , dtype = np .uint64 )
459+ if np .prod (full_shape ) <= max_size :
459460 return arr [:] # no need to subsample if already below the threshold
460461
461462 # get factor by which to divide all dims
462- f = np .power ((np .prod (arr . shape ) / max_size ), 1.0 / arr .ndim )
463+ f = np .power ((np .prod (full_shape ) / max_size ), 1.0 / arr .ndim )
463464
464465 # new shape for subsampled array
465- ns = np .floor (np .array (arr . shape ) / f ).clip (min = 1 )
466+ ns = np .floor (np .array (full_shape ) / f ).clip (min = 1 )
466467
467468 # get the step size for the slices
468- slices = tuple (
469- slice (None , None , int (s )) for s in np .floor (arr . shape / ns ).astype (int )
469+ slices = list (
470+ slice (None , None , int (s )) for s in np .floor (full_shape / ns ).astype (int )
470471 )
471472
472473 # ignore dims e.g. RGB, which we don't want to downsample
You can’t perform that action at this time.
0 commit comments