Skip to content

Let the Linear TS adapter generate guesses for requested atom maps - #1044

Open
kfir4444 wants to merge 2 commits into
mainfrom
linear_adapter_explicit_atom_map
Open

Let the Linear TS adapter generate guesses for requested atom maps#1044
kfir4444 wants to merge 2 commits into
mainfrom
linear_adapter_explicit_atom_map

Conversation

@kfir4444

@kfir4444 kfir4444 commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

LinearAdapter derives an atom map per reaction path via map_rxn and never reads a map set on the reaction, so pre-setting one changed nothing and was not reported. This adds LinearAdapter(atom_map=...), taking one map or several: each requested map replaces the derived one for a full pass over the weight grid, so a TS guess can be requested for a specific reactants-to-products correspondence. Requested maps are validated (permutation, atom count, element-preserving) and unusable ones are reported rather than silently dropped. A pre-set rxn.atom_map still does not take part in the derivation - other adapters populate it as a side effect of reading it - but the adapter now warns that it is unused and points at the new argument, and the docstrings say guesses are generated per product dictionary.

Closes #1042

@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.56%. Comparing base (484c678) to head (d545be9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1044   +/-   ##
=======================================
  Coverage   65.55%   65.56%           
=======================================
  Files         121      121           
  Lines       41073    41121   +48     
  Branches    10566    10579   +13     
=======================================
+ Hits        26927    26959   +32     
- Misses      11117    11126    +9     
- Partials     3029     3036    +7     
Flag Coverage Δ
functionaltests 65.56% <ø> (+<0.01%) ⬆️
unittests 65.56% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@calvinp0
calvinp0 force-pushed the linear_adapter_explicit_atom_map branch from 10e4352 to d545be9 Compare September 8, 2026 09:21
if uni_is_product:
try:
atom_map = cached_map_rxn(rxn=rxn, product_dict_index=i, map_cache=map_cache)
atom_map = cached_map_rxn(rxn=rxn, product_dict_index=i, map_cache=map_cache,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the requested atom map can still be ignored in some cases. when a molecule splits into fragments, parts of the code still choose their own atom correspondence. so you ask for map a, and you may instead receive another map, reported as successful

@calvinp0 calvinp0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just one comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LinearAdapter silently ignores a pre-set atom map, returning identical TS guesses for different maps

2 participants