1414
1515import numpy as np
1616
17+ from curve_apps .peak_finder .anomaly import Anomaly
1718from curve_apps .peak_finder .anomaly_group import AnomalyGroup
1819from curve_apps .peak_finder .line_data import LineData
1920from curve_apps .peak_finder .line_position import LinePosition
@@ -282,11 +283,12 @@ def group_n_groups(self, groups: list[AnomalyGroup]) -> list[AnomalyGroup]:
282283
283284 return_groups : list [AnomalyGroup ] = []
284285 all_starts = np .array ([group .start for group in groups ])
285- sort_inds = np .argsort (all_starts )
286- sorted_groups : list [AnomalyGroup ] = list (np .array (groups )[sort_inds ])
287-
288- max_separation = np .ceil (self .max_separation / self .position .sampling )
289- neighbours_list = self .find_neighbour_groups (sorted_groups , max_separation )
286+ sorted_groups : list [AnomalyGroup ] = list (
287+ np .array (groups )[np .argsort (all_starts )]
288+ )
289+ neighbours_list = self .find_neighbour_groups (
290+ sorted_groups , np .ceil (self .max_separation / self .position .sampling )
291+ )
290292
291293 if len (neighbours_list ) == 0 :
292294 return return_groups
@@ -304,8 +306,12 @@ def group_n_groups(self, groups: list[AnomalyGroup]) -> list[AnomalyGroup]:
304306 if len (indices ) < self .n_groups :
305307 continue
306308
309+ anomalies : list [Anomaly ] = []
310+ for ind in indices :
311+ anomalies += sorted_groups [ind ].anomalies .tolist ()
312+
307313 new_group = AnomalyGroup (
308- np . concatenate ([ sorted_groups [ ind ]. anomalies for ind in indices ]) ,
314+ anomalies ,
309315 self .property_group ,
310316 subgroups = {sorted_groups [ind ] for ind in indices },
311317 )
0 commit comments