fix: HeartRateExtractor.extract() PyO3 binding misnames Rust phases param as weights#1290
Open
mvanhorn wants to merge 1 commit into
Open
fix: HeartRateExtractor.extract() PyO3 binding misnames Rust phases param as weights#1290mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
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.
Summary
HeartRateExtractor.extract()now takes aphasesargument that matches the Rust core, so the documented call path returns real estimates instead of always returningNone.Why this matters
Issue #1225 reports that
hr.extract(residuals=..., weights=[])always returnsNone. The PyO3 binding named the second parameterweights, but the Rust core requires per-subcarrier unwrapped phases:Because the sample count is clamped by
phases.len(), passing the documentedweights=[]setsn = 0and the extractor returnsNonefor every frame.HeartRateExtractoris notBreathingExtractor: it needs phase data, so an empty second argument is never valid.Changes
weights->phasesand pass it straight through to the core, so the Python API name reflects what the DSP actually consumes.phases=[]is invalid for heart-rate extraction.Testing
Added
test_heart_rate_extract_with_synthetic_signal_and_phases(drives a synthetic 1.2 Hz / 72 BPM signal with matching phase data and asserts a finite BPM and a confidence in[0, 1]) andtest_heart_rate_extract_rejects_old_weights_keyword(asserts the removedweights=keyword now raisesTypeError). The parameter rename matches the core signature atheartrate.rs:100.Fixes #1225