Skip to content

fix: linear-interpolation#161

Open
binary69 wants to merge 5 commits intosensorium-competition:mainfrom
binary69:fix/linear-interpolation
Open

fix: linear-interpolation#161
binary69 wants to merge 5 commits intosensorium-competition:mainfrom
binary69:fix/linear-interpolation

Conversation

@binary69
Copy link
Copy Markdown
Contributor

Closes #160

Fixes the linear interpolation in PhaseShiftedSequenceInterpolator.interpolate and SequenceInterpolator.interpolate

Copilot AI review requested due to automatic review settings April 15, 2026 11:31
@gitnotebooks
Copy link
Copy Markdown

gitnotebooks bot commented Apr 15, 2026

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes linear interpolation time calculations when start_time != 0 for both SequenceInterpolator and PhaseShiftedSequenceInterpolator, and extends tests to cover non-zero start times (issue #160).

Changes:

  • Add start_time when computing times_lower/times_upper in SequenceInterpolator.interpolate (linear mode).
  • Add start_time and per-signal phase shifts to times_lower/times_upper in PhaseShiftedSequenceInterpolator.interpolate (linear mode), and adjust numerator computation accordingly.
  • Expand linear interpolation tests to run with start_time set to 0.0 and 15.0.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
experanto/interpolators.py Corrects linear interpolation time math to account for non-zero start_time (and phase shifts for the phase-shifted interpolator).
tests/test_sequence_interpolator.py Adds coverage for start_time != 0 in linear interpolation tests.
diff_output.txt Newly added artifact file containing an encoded diff; appears unintended.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread experanto/interpolators.py Outdated
@binary69
Copy link
Copy Markdown
Contributor Author

hey @pollytur @schewskone did the changes, happy to get a review :)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes linear interpolation correctness when start_time != 0 for sequence-based interpolators, aligning computed sample times with the underlying timestamp origin (and per-signal phase shifts).

Changes:

  • Correct SequenceInterpolator.interpolate(..., interpolation_mode="linear") to include start_time in times_lower/times_upper.
  • Correct PhaseShiftedSequenceInterpolator.interpolate(..., interpolation_mode="linear") to include start_time (and phase shifts) in times_lower/times_upper, and apply the overflow row mask consistently to all derived arrays.
  • Extend linear interpolation tests to cover non-zero start_time.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
experanto/interpolators.py Fixes linear interpolation time math for non-zero start_time (and phase-shifted linear path), ensuring correct weight computation and consistent masking.
tests/test_sequence_interpolator.py Expands linear interpolation test parametrization to validate behavior when start_time is non-zero.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@schewskone schewskone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing this.

times_lower = (
self.start_time
+ (idx_lower * self.time_delta)
+ self._phase_shifts[np.newaxis, :]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@binary69 why are there self._phase_shifts[ here now while they were not there before

Copy link
Copy Markdown
Contributor Author

@binary69 binary69 Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved it there because the earlier version was just doing the same calculation in additional lines. Changed it since it'll make the code more readable

times_upper = (
self.start_time
+ (idx_upper * self.time_delta)
+ self._phase_shifts[np.newaxis, :]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here - @binary69 why are there self._phase_shifts[ here now while they were not there before

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.

start_time missing from times_lower/times_upper in linear interpolation

4 participants