Step 3: vectorize SampleShifterLinear row shifting#86
Open
mschwoer wants to merge 5 commits into
Open
Conversation
Add regression tests before vectorizing _shift_columns_to_reference_sample: each row shifted by nanmedian(reference - row), partial-NaN rows handled via nanmedian skipna, all-NaN rows stay NaN, and a row already on the reference is unchanged. Tests pass against the unmodified baseline. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the per-row pandas Series-alignment shift (iloc[r,:] += distance) with one numpy block: compute all row shifts via nanmedian(reference - values, axis=1) and apply with a single iloc[:,:] write. nanmedian already yields NaN for all-NaN rows, matching the old _calc_distance. Adds the shared `import warnings`. Bit-identical protein + ion output (max_abs_diff=0); suite passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… test --- # Conversation that produced these changes --- ## User prompt "resolve the "follow-ups are cleanliness (dead method) and one test-coverage gap"" ## Clarifying round 1 Q: How far should the dead-code cleanup go? - Remove method + _calc_distance + its tests <-- chosen - Remove only _shift_to_reference_sample Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Replaces the per-row pandas Series-alignment shift (
iloc[r,:] += distance) with one numpy block: all row shifts viananmedian(reference - values, axis=1)applied in a single write.Estimated speedup: estimate stage 116.9 s → 102.8 s (~1.14×), single-core HYE benchmark.
Bit-identical protein + ion output (
max_abs_diff=0); suite passes.🤖 Generated with Claude Code