diff --git a/neatnet/artifacts.py b/neatnet/artifacts.py index 7309a4e..6a190a6 100644 --- a/neatnet/artifacts.py +++ b/neatnet/artifacts.py @@ -1073,10 +1073,6 @@ def nx_gx( # correctly pick-up the highest hierarchy and drop all lower if artifact.C > 0: logger.debug("HIGHEST C") - # define mask for E and S strokes - es_mask = edges.coins_group.isin(all_ends.coins_group) - # filter Cs - highest_hierarchy = edges[~es_mask] else: logger.debug("HIGHEST E") singles = set() @@ -1089,12 +1085,14 @@ def nx_gx( ): singles.add(group) visited.append(group) - # filter ends + # re-filter ends all_ends = edges[edges.coins_group.isin(singles)] - # define mask for E and S strokes - es_mask = edges.coins_group.isin(all_ends.coins_group) - # filter Cs - highest_hierarchy = edges[~es_mask] + + # define mask for E and S strokes + es_mask = edges.coins_group.isin(all_ends.coins_group) + + # filter Cs + highest_hierarchy = edges[~es_mask] # get nodes forming the artifact relevant_nodes = nodes.iloc[