Location: bionetgen/modelapi/pattern.py:626
Original marker:
# TODO: try to decide if A(b!1).B(a!1) is the same
# as A(b!2).B(a!2), if so, the bond check is much harder
Component.__eq__ (and through it, Molecule/Pattern equality) compares bonds as raw label tokens. Two BNGL patterns that differ only in the labels of their bonds are semantically identical — A(b!1).B(a!1) and A(b!2).B(a!2) represent the same complex — but the equality check returns False. The author's commented-out attempt to compare bonds as sets sits below the marker.
Recent context: 421bac9 (Fix Pattern/Molecule equality and mutable defaults) addressed the worst case (mutable defaults causing unrelated patterns to compare equal). This issue is the remaining correctness gap.
What would unblock this: decide between two resolutions:
- Normalize bond labels. Relabel each pattern's bonds in canonical order before comparing. Adds correctness but means equality is no longer a string-identity check.
- Document the limitation. Keep the current label-sensitive equality, add a docstring explaining that callers should canonicalize first.
If a current consumer depends on label-normalized equality (e.g. structural pattern dedup in the simulator bridge), please note it on this issue so the resolution scope is clear.
Discovered during: non-Atomizer TODO/FIXME triage sweep, 2026-05-08.
Location:
bionetgen/modelapi/pattern.py:626Original marker:
Component.__eq__(and through it,Molecule/Patternequality) compares bonds as raw label tokens. Two BNGL patterns that differ only in the labels of their bonds are semantically identical —A(b!1).B(a!1)andA(b!2).B(a!2)represent the same complex — but the equality check returnsFalse. The author's commented-out attempt to compare bonds as sets sits below the marker.Recent context:
421bac9(Fix Pattern/Molecule equality and mutable defaults) addressed the worst case (mutable defaults causing unrelated patterns to compare equal). This issue is the remaining correctness gap.What would unblock this: decide between two resolutions:
If a current consumer depends on label-normalized equality (e.g. structural pattern dedup in the simulator bridge), please note it on this issue so the resolution scope is clear.
Discovered during: non-Atomizer TODO/FIXME triage sweep, 2026-05-08.