Repository navigation
Conversation
Time contact-pair distances on the 1gya structure, including the periodic-box case, so later timing changes can be compared. Co-Authored-By: Aiden <aiden@weco.ai>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
index_distance()first, as the contribution guide requires.pytest -q tests/structure/test_geometry.py tests/structure/test_compare.py.What & Why
The old calculation read three adjacent values per contact pair. NumPy can sum across many pairs faster when each component occupies its own contiguous block.
The layout check keeps the order of the model and pair axes. The same dot product adds the same three terms for each distance.
Results
Calls with one or ten pairs took longer. The first measured gain was at 100 pairs. A direct two-atom distance took 1.79 µs before and 1.88 µs after.
The full
lddt()calculation took 150.62 ms before and 119.90 ms after.Three runs of the mixed workload gave these results on x86-64.
With default thread settings, the four-call loop took 82.32 ms before and 40.95 ms after (ratio 0.497). These figures are from our measurements. The repository benchmark job will compare the same function before and after the optimization commit.
Validation
The public timing command reports milliseconds per four-call loop.
python -m timeit -n 5 -r 9 -s "import numpy as np, biotite.structure as struc, biotite.structure.io.pdbx as pdbx; a = pdbx.get_structure(pdbx.BinaryCIFFile.read('tests/structure/data/pdb/1gya.bcif')); a = a[..., struc.filter_heavy(a)]; f = a[0]; p = np.argwhere(np.triu(struc.CellList(f, 15.0).create_adjacency_matrix(15.0), k=1)); b = np.diag(np.ptp(f.coord, axis=0) + 30.0).astype(np.float32)" "struc.index_distance(f, p); struc.index_distance(a, p); struc.index_distance(f.coord, p); struc.index_distance(f, p, periodic=True, box=b)"Run the native tests from the repository root.
Why this is safe and easy to maintain
The small layout check keeps the shared distance formula. The output stays unchanged for masked arrays and ndarray subclasses. The regression tests cover partial masks, full masks, and ndarray subclass dispatch through both public functions.
AI assistance
This PR was prepared with AI assistance from Aiden. Candidates were tracked with Weco Observe.
Weco share link: https://dashboard.weco.ai/share/9bvUA5sg01NabkvFn4am1_S_GfdywmDu