Skip to content

Step 3: vectorize SampleShifterLinear row shifting#86

Open
mschwoer wants to merge 5 commits into
opt/step2-vectorize-determine-sorted-rowsfrom
opt/step3-vectorize-sample-shifter
Open

Step 3: vectorize SampleShifterLinear row shifting#86
mschwoer wants to merge 5 commits into
opt/step2-vectorize-determine-sorted-rowsfrom
opt/step3-vectorize-sample-shifter

Conversation

@mschwoer

Copy link
Copy Markdown
Contributor

Replaces the per-row pandas Series-alignment shift (iloc[r,:] += distance) with one numpy block: all row shifts via nanmedian(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

mschwoer and others added 5 commits June 15, 2026 13:40
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>
@mschwoer mschwoer requested a review from ammarcsj June 16, 2026 08:49
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.

1 participant