@@ -332,7 +332,6 @@ def reorder_by_depth(
332332 geom : np .ndarray | None = None ,
333333 centroids : np .ndarray | None = None ,
334334 in_place : bool = False ,
335- is_flat : bool = False ,
336335) -> tuple [DARTsortSorting , np .ndarray ]:
337336 """Reorder cluster labels so that centroid depth is increasing
338337
@@ -350,9 +349,7 @@ def reorder_by_depth(
350349 reorder: np.ndarray
351350 reorder[j] is the new label of original unit j.
352351 """
353-
354- if not is_flat :
355- sorting = sorting .flatten (include_gmm_properties = True , in_place = in_place )
352+ sorting = sorting .flatten (include_gmm_properties = True , in_place = in_place )
356353 assert sorting .labels is not None
357354
358355 if geom is None and motion is not None :
@@ -540,9 +537,11 @@ def decrumb_labels(labels: np.ndarray, min_size: int = 5, in_place=False, flatte
540537 The (flattened) decrumbed labels.
541538 """
542539 units , counts , _ = pos_int_unique_and_counts (labels )
540+ if not units .size :
541+ return labels
543542 all_big = counts .min () >= min_size
544543 flat_ok = (not flatten ) or np .array_equal (units , np .arange (len (units )))
545- if ( not units . size ) or ( all_big and flat_ok ) :
544+ if all_big and flat_ok :
546545 return labels
547546 remapping = np .full ((units .max () + 1 ,), - 1 , dtype = labels .dtype )
548547 kept_units = units [counts >= min_size ]
@@ -561,7 +560,11 @@ def decrumb(
561560) -> DARTsortSorting :
562561 assert sorting .labels is not None
563562 units , counts , _ = pos_int_unique_and_counts (sorting .labels )
564- if (not units .size ) or (counts .min () >= min_size ):
563+ if not units .size :
564+ return sorting
565+ all_big = counts .min () >= min_size
566+ flat_ok = (not flatten ) or np .array_equal (units , np .arange (len (units )))
567+ if all_big and flat_ok :
565568 return sorting
566569
567570 remapping = np .full ((units .max () + 1 ,), - 1 , dtype = sorting .labels .dtype )
0 commit comments