nettracer3d 1.2.7__py3-none-any.whl → 1.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -923,8 +923,15 @@ def get_distance_list(centroids, network, xy_scale, z_scale):
923
923
  return distance_list
924
924
 
925
925
 
926
- def prune_samenode_connections(networkfile, nodeIDs):
927
- """Even faster numpy-based version for very large datasets"""
926
+ def prune_samenode_connections(networkfile, nodeIDs, target=None):
927
+ """Even faster numpy-based version for very large datasets
928
+
929
+ Args:
930
+ networkfile: Network file path or list of node pairs
931
+ nodeIDs: Node identity mapping (file path or dict)
932
+ target: Optional string. If provided, only prunes pairs where BOTH nodes
933
+ have this specific identity. If None, prunes all same-identity pairs.
934
+ """
928
935
  import numpy as np
929
936
 
930
937
  # Handle nodeIDs input
@@ -953,8 +960,13 @@ def prune_samenode_connections(networkfile, nodeIDs):
953
960
  idsA = np.array([data_dict.get(node) for node in nodesA])
954
961
  idsB = np.array([data_dict.get(node) for node in nodesB])
955
962
 
956
- # Create boolean mask - keep where IDs are different
957
- keep_mask = idsA != idsB
963
+ # Create boolean mask based on target parameter
964
+ if target is None:
965
+ # Original behavior: keep where IDs are different
966
+ keep_mask = idsA != idsB
967
+ else:
968
+ # New behavior: only remove pairs where BOTH nodes have the target identity
969
+ keep_mask = ~((idsA == target) & (idsB == target))
958
970
 
959
971
  # Apply filter
960
972
  filtered_nodesA = nodesA[keep_mask].tolist()