You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Return an empty array from segment-wise functions for an empty atom array - #1032
Since #889, get_residue_starts(empty, add_exclusive_stop=True) is [0], so the loop in apply_segment_wise() never runs and the initial None is returned. The comment saying the loop runs at least once no longer holds, so I removed it.
With no segments function is never called, so the shape and dtype of its return value are unknown. This PR uses the dtype of data and its shape without axis: (0,) without axis, (0, 3) for coordinates with axis=0. Happy to change that if you'd rather have something else, e.g. always float.
A related empty-input case: get_residue_positions(empty, []) and get_residue_starts_for(empty, []) raise IndexError. np.asarray([]) is a float array, and with 0 >= 0 the lookup-table branch indexes with it. Empty indices now return an empty int array.
Tests: the new empty-input tests fail on main (None, IndexError) and pass with the change. I couldn't build main here (no Rust toolchain), so I ran tests/structure against the 2.0.0 wheel with the patched segments.py swapped in (the file is identical to main before this change): no new failures. ruff check, ruff format --diff, numpydoc lint and pyright at the lock-file versions are clean.
AI assistance: drafted with Claude Opus 5.5 (claude-opus-5-5); I ran the checks above.
Merging this PR will degrade performance by 39.88%
1 warning
⚠️19 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.
No successful run was found on main (f7eb9c6) during the generation of this report, so 2effe8f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
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
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.
apply_residue_wise(),apply_chain_wise()andapply_segment_wise()returnNonefor an emptyAtomArray, although they are typed to return anndarray:Since #889,
get_residue_starts(empty, add_exclusive_stop=True)is[0], so the loop inapply_segment_wise()never runs and the initialNoneis returned. The comment saying the loop runs at least once no longer holds, so I removed it.With no segments
functionis never called, so the shape and dtype of its return value are unknown. This PR uses the dtype ofdataand its shape withoutaxis:(0,)withoutaxis,(0, 3)for coordinates withaxis=0. Happy to change that if you'd rather have something else, e.g. alwaysfloat.A related empty-input case:
get_residue_positions(empty, [])andget_residue_starts_for(empty, [])raiseIndexError.np.asarray([])is a float array, and with0 >= 0the lookup-table branch indexes with it. Empty indices now return an empty int array.Tests: the new empty-input tests fail on main (
None,IndexError) and pass with the change. I couldn't build main here (no Rust toolchain), so I rantests/structureagainst the 2.0.0 wheel with the patchedsegments.pyswapped in (the file is identical to main before this change): no new failures.ruff check,ruff format --diff,numpydoc lintandpyrightat the lock-file versions are clean.AI assistance: drafted with Claude Opus 5.5 (
claude-opus-5-5); I ran the checks above.