Skip to content

Fix check_in_box() returning atoms inside the box - #1037

Open
rpinho wants to merge 2 commits into
biotite-dev:mainfrom
rpinho:fix-outside-box
Open

rpinho wants to merge 2 commits into
biotite-dev:mainfrom
rpinho:fix-outside-box

Conversation

@rpinho

@rpinho rpinho commented Nov 18, 2026

Copy link
Copy Markdown

check_in_box() returns indices of atoms inside the periodic box although its API promises indices outside it.
With a box of side 10 and atoms at x=1, x=-1 and x=11, it returns [0] instead of [1, 2].
The patch inverts the selection and documents the upper boundary used by the box convention.
Regression tests cover orthogonal and triclinic boxes, inside and outside selections, empty selections, and a missing box.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N

@rpinho

rpinho commented Nov 24, 2026

Copy link
Copy Markdown
Author

Let me know if you have any thoughts on this one.

@padix-key

Copy link
Copy Markdown
Member

This PR fixes #1049, so it will close that issue.

Authored by Claude

@codspeed

codspeed Bot commented Nov 26, 2026

Copy link
Copy Markdown

Merging this PR will regress 6 benchmarks

2 warnings

⚠️ 20 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 20 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

⚡ 14 improved benchmarks
❌ 6 regressed benchmarks
✅ 91 untouched benchmarks
⏩ 14 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ benchmark_match_kmer_selection[KmerTable-None] 526.4 µs 636.8 µs -17.35%
❌ benchmark_match[KmerTable-None] 623.9 µs 731.4 µs -14.7%
❌ benchmark_match_kmer_selection[BucketKmerTable(10000)-None] 653.5 µs 765.9 µs -14.67%
❌ benchmark_match_kmer_selection[BucketKmerTable(10000)-11*11*1*1***111] 652.7 µs 763.6 µs -14.53%
❌ benchmark_match[BucketKmerTable(10000)-None] 760.6 µs 870.4 µs -12.62%
❌ benchmark_match[BucketKmerTable(10000)-11*11*1*1***111] 838.9 µs 948.5 µs -11.55%
⚡ benchmark_conversion[bond_type_matrix] 3 ms 1.4 ms ×2.2
⚡ benchmark_conversion[adjacency_matrix] 3 ms 1.4 ms ×2.2
⚡ benchmark_align_pairwise[align_local_gapped-score_only] 120.1 ms 81.2 ms +47.95%
⚡ benchmark_align_pairwise[align_optimal-score_only] 148.8 ms 107.2 ms +38.83%
⚡ benchmark_indexing_from_kmer_selection[11*11*1*1***111-KmerTable] 15.2 ms 11.3 ms +34.38%
⚡ benchmark_indexing_from_kmer_selection[None-KmerTable] 15.2 ms 11.4 ms +34.19%
⚡ benchmark_indexing_from_kmers[None-KmerTable] 15 ms 11.2 ms +33.93%
⚡ benchmark_indexing_from_kmers[11*11*1*1***111-KmerTable] 15 ms 11.2 ms +33.88%
⚡ benchmark_get_assembly 835.9 ms 638.3 ms +30.97%
⚡ benchmark_indexing_from_sequences[None-KmerTable] 21.8 ms 17.6 ms +23.94%
⚡ benchmark_cell_list_compute_contacts[MASK] 34.7 ms 28.8 ms +20.33%
⚡ benchmark_indexing_from_sequences[11*11*1*1***111-KmerTable] 36.6 ms 32.1 ms +13.73%
⚡ benchmark_find_connected 975.5 µs 872.5 µs +11.8%
⚡ benchmark_decode 6.4 ms 5.7 ms +11.38%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rpinho:fix-outside-box (7f024ca) with main (2effe8f)

Open in CodSpeed

Footnotes

  1. 14 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@padix-key padix-key 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.

Thanks for the fix, I left only a nit below.

def test_duplicate_atoms_check(duplicate_sample_array):
discon = struc.check_duplicate_atoms(duplicate_sample_array)
assert discon.tolist() == [42, 234]

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.

Could you add a docstring to these two tests explaining what the test checks and how it is doing it?

@rpinho

rpinho commented Nov 27, 2026

Copy link
Copy Markdown
Author

Thanks! I've done this.

This branch has not been deployed

No deployments
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.

2 participants