[1/5] Tests: characterize flatten_fragments before the memory refactor - #434
Open
GeorgWa wants to merge 1 commit into
Open
[1/5] Tests: characterize flatten_fragments before the memory refactor#434GeorgWa wants to merge 1 commit into
GeorgWa wants to merge 1 commit into
Conversation
flatten_fragments had no unit test. Add black-box tests that pin its contract, so the refactoring that follows can be checked step by step. `_dense_library` builds dense frames with mz == 0 padding from both sources that produce it: unmodified precursors carry no modloss fragments, and some fragments fall outside the mz range. Intensities are distinct, so the top-k selection is unambiguous. `_expected_keep_mask` derives the expected mask per precursor, without flatten_fragments. The tests cover the kept fragments over five combinations of `keep_top_k_fragments` and `min_fragment_intensity`, every annotation column, the reannotated precursor pointers, `custom_df` and `custom_columns`, the path without intensities, an empty library, and a precursor long enough to need more than a uint8 fragment number. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
mschwoer
reviewed
Aug 31, 2026
| @pytest.mark.requires_numba | ||
| def test_flatten_fragments_long_precursor(): | ||
| """A long precursor keeps fragment numbers above 255, and the columns stay uint32.""" | ||
| n_rows = 260 # close to the max_frag_per_peptide limit of _fill_in_indices |
| def _expected_keep_mask( | ||
| precursor_df, mz_df, intensity_df, keep_top_k_fragments, min_fragment_intensity | ||
| ): | ||
| """Give the keep mask over all dense slots. This does not use flatten_fragments.""" |
Contributor
There was a problem hiding this comment.
could we add a test for this?
Contributor
There was a problem hiding this comment.
seriously, could we not work with statically define input data (and data to assert against)?
such minimal data models would also help understand/debug the code better one day
Collaborator
Author
There was a problem hiding this comment.
@mschwoer do you mean we SHOULD work with static examples or we should keep this logic?
Contributor
There was a problem hiding this comment.
we should "strongly consider"™️ it :-D
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.
Tests only. No production change.
flatten_fragmentshad no unit test. Add black-box tests that pin its contract, so the refactoring that follows can be checked step by step.All tests pass unchanged on
main.First of 5 stacked PRs splitting #429.
🤖 Generated with Claude Code