Skip to content

Commit

Permalink
Filter out automorphisms more efficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCBrammer committed Dec 21, 2024
1 parent 8fd73f8 commit 6e0c24d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 3 additions & 4 deletions docs/refinement_tree.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,14 @@
"source": [
"## Feedback on performance and correctness\n",
"\n",
"Currently (HEAD commit on `main` at December 04) `pytest tests/test_canonicalization.py::test_permutation_invariance` fails for 4 structures (exclusively timeout failures, no invariance failures):\n",
"Currently (HEAD commit on `main` at December 21) `pytest tests/test_canonicalization.py::test_permutation_invariance` fails for 3 structures (exclusively timeout failures, no invariance failures):\n",
"\n",
"```\n",
"============================================================= short test summary info =============================================================\n",
"FAILED tests/test_canonicalization.py::test_permutation_invariance[C28_H36_N8_Zn_C_F3_S_O3_2_C4_H8_O_in_Pca21] - Failed: Timeout >10.0s\n",
"======================================================== short test summary info ========================================================\n",
"FAILED tests/test_canonicalization.py::test_permutation_invariance[C240] - Failed: Timeout >10.0s\n",
"FAILED tests/test_canonicalization.py::test_permutation_invariance[C180] - Failed: Timeout >10.0s\n",
"FAILED tests/test_canonicalization.py::test_permutation_invariance[C36_H72_Cl4_N14_Zn2_0_5_CH3CN_2_5_Et2O_in_P-1] - Failed: Timeout >10.0s\n",
"==================================================== 4 failed, 229 passed in 148.72s (0:02:28) ====================================================\n",
"=============================================== 3 failed, 230 passed in 118.62s (0:01:58) ===============================================\n",
"\n",
"```\n",
"\n",
Expand Down
7 changes: 2 additions & 5 deletions tucan/canonicalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,9 @@ def filter_out_automorphisms(ms: list[nx.Graph]) -> list[nx.Graph]:
labelings = set()

for m in ms:
m_relabeled_by_partition = nx.relabel_nodes(
m,
dict(zip(list(m), nx.get_node_attributes(m, PARTITION).values())),
)
partitions = list(nx.get_node_attributes(m, PARTITION).values())
labeling = tuple(
sorted([tuple(sorted(edge)) for edge in m_relabeled_by_partition.edges()])
sorted([tuple(sorted(partitions[n] for n in edge)) for edge in m.edges()])
)

if labeling in labelings:
Expand Down

0 comments on commit 6e0c24d

Please sign in to comment.