Refactor baseline threading helper and centralize baseline selection#17
Refactor baseline threading helper and centralize baseline selection#17
Conversation
💡 Codex ReviewLine 2006 in 822da2b When ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #17 +/- ##
===========================================
- Coverage 89.45% 88.71% -0.74%
===========================================
Files 12 13 +1
Lines 1631 1764 +133
Branches 205 222 +17
===========================================
+ Hits 1459 1565 +106
- Misses 132 151 +19
- Partials 40 48 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db92c4b47a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if result.ndim != 2: | ||
| raise ValueError( | ||
| "Applied function must return a scalar or a 1D array for each slice." |
There was a problem hiding this comment.
Allow apply outputs with >1D per slice
The new _reshape_apply_result now raises when the applied callable returns anything other than a scalar or 1D vector per slice. Previously apply() delegated to numpy.apply_along_axis and preserved higher‑dimensional outputs (e.g., a function returning a 2D matrix per spectrum would yield a 3D result). This change turns previously-valid custom preprocessing functions into hard errors, even though the apply docstring still says it accepts any callable suitable for np.apply_along_axis. Users computing per-spectrum feature matrices or multi-channel transforms will now fail with ValueError in serial mode, which is a regression introduced here.
Useful? React with 👍 / 👎.
Motivation
single_threadedAPI as a keyword-only option onSpectraFrame.baselinefor clarity and backward compatibility.Description
_thread_baseline_func(wl, method, kwargs)that returns a callable performing baseline estimation for a single spectrum using eitherrubberbandor apybaselines.Baselinemethod.SpectraFrame.baselineto accept*, single_threaded: bool = Trueand to use_thread_baseline_funcfor the single-threaded path (viaself.apply) and for each worker in the multithreaded path (viaThreadPoolExecutor).baseline.single_threadedoption indocs/user-guide/manipulation.mdand addedtest_baseline_threadedtotests/test_spectra.pyto exercise the threaded path.Testing
pytest tests/test_spectra.py -k baseline, which executed the baseline-related tests and reported success (2 passed, 67 deselected).Codex Task