Skip to content

Commit

Permalink
patch: logic for sign insensitive and strict PDG check #152
Browse files Browse the repository at this point in the history
  • Loading branch information
jacanchaplais committed Sep 11, 2023
1 parent 0b1fb00 commit 6b91667
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions graphicle/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,17 +656,20 @@ def hard_descendants(
del hard_mask["incoming"]
hard_graph = graph[hard_mask]
if target is not None:
target_pdgs = set(target)
target_pdgs = set(target) if sign_sensitive else set(map(abs, target))
target_mask = hard_graph.pdg.mask(
target=tuple(target_pdgs),
blacklist=False,
sign_sensitive=sign_sensitive,
)
if not np.any(target_mask):
raise ValueError("No target PDGs found in hard process.")
if (strict is True) and (np.sum(target_mask) != len(target_pdgs)):
found_pdgs = set(map(int, hard_graph.pdg[target_mask]))
missing_pdgs = target_pdgs - found_pdgs
found_pdgs_ = hard_graph.pdg[target_mask]
if not sign_sensitive:
found_pdgs_ = np.abs(found_pdgs_)
found_pdgs = set(found_pdgs_)
missing_pdgs = target_pdgs - found_pdgs
if strict and missing_pdgs:
missing_str = ", ".join(map(str, missing_pdgs))
raise ValueError(f"Missing PDGs in hard process: {missing_str}.")
hard_graph = hard_graph[target_mask]
Expand Down

0 comments on commit 6b91667

Please sign in to comment.