Skip to content

Standardize empty-query behavior across interpolators#145

Open
ojasvatsyayan wants to merge 14 commits intosensorium-competition:mainfrom
ojasvatsyayan:fix-interpolator-consistency
Open

Standardize empty-query behavior across interpolators#145
ojasvatsyayan wants to merge 14 commits intosensorium-competition:mainfrom
ojasvatsyayan:fix-interpolator-consistency

Conversation

@ojasvatsyayan
Copy link
Copy Markdown

This PR improves consistency across interpolators for edge cases where no valid times are provided

Changes:
Added warning + empty return handling to SpikeInterpolator
Ensured consistent empty return shape and dtype across interpolators
Preserved existing SequenceInterpolator warning behavior to maintain test compatibility

All existing tests pass locally

Note: SequenceInterpolator and PhaseShiftedSequenceInterpolator warning messages were intentionally left unchanged to preserve compatibility with existing tests

@gitnotebooks
Copy link
Copy Markdown

gitnotebooks bot commented Mar 19, 2026

@reneburghardt reneburghardt requested a review from Copilot March 19, 2026 07:32
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 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

This PR aims to standardize how interpolators behave when no valid query times are provided, focusing on consistent warning behavior and consistent empty return outputs across interpolator implementations.

Changes:

  • Updated empty-query handling paths in SequenceInterpolator, PhaseShiftedSequenceInterpolator, TimeIntervalInterpolator, and SpikeInterpolator.
  • Adjusted warning messaging for empty-query cases to improve consistency.
  • Renamed ScreenInterpolator’s internal cache flag from cache_trials to cache_data and updated its usage when constructing trials.

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

@pollytur pollytur requested a review from Copilot March 19, 2026 09:55
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

This PR standardizes how interpolators behave when interpolation is requested with no valid times (empty-query), aiming for consistent empty return shapes/dtypes and consistent warning behavior across modalities.

Changes:

  • Updated SequenceInterpolator and PhaseShiftedSequenceInterpolator empty-query paths to return empty arrays with an explicit dtype matching the underlying data.
  • Standardized the “no valid times” warning message used by TimeIntervalInterpolator and SpikeInterpolator and added the warning to SpikeInterpolator’s empty-query path.
  • Renamed ScreenInterpolator’s internal cache flag from cache_trials to cache_data and propagated it into trial creation.

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

You can also share your feedback on Copilot code review. Take the survey.

@pollytur
Copy link
Copy Markdown
Contributor

@ojasvatsyayan could we please merge main into the current branch and also make the CI/CD pass (currently failing at black / isort)

@ojasvatsyayan
Copy link
Copy Markdown
Author

merged latest main, resolved CI issues, ensured formatting + linting pass. ready for review @pollytur @reneburghardt

Copy link
Copy Markdown
Contributor

@pollytur pollytur left a comment

Choose a reason for hiding this comment

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

@ojasvatsyayan

Note: SequenceInterpolator and PhaseShiftedSequenceInterpolator warning messages were intentionally left unchanged to preserve compatibility with existing tests

what specifically does this mean?

also, if the goal of the PR is to improve consistency - that means you need to make the warnings more consistent and adjust the tests if needed.

plus see the comments to the code changes - in 2 places type should be bool.
Otherwise I see no special value on specifying dtype of the empty array - might remove it for simplicity but no strong opinion

@ojasvatsyayan ojasvatsyayan force-pushed the fix-interpolator-consistency branch from f09145f to 1dc88a9 Compare March 20, 2026 03:01
@ojasvatsyayan
Copy link
Copy Markdown
Author

Hi @pollytur ,

Thank you for the feedback. I have now standardized warning message across all interpolators("No valid times provided for interpolation"), ensured all warnings use UserWarning, fixed dtype inconsistencies, removed duplicate warning calls, and updated the test suite accordingly. All tests pass locally, ready for re-review!

Additionally, I’ve been exploring the event-driven data handling in the codebase and am particularly interested in how spike data integrates into the overall pipeline. I started a discussion in the repo and would be happy to continue there, are there any specific directions you'd like me to look into next?

Thanks again for your guidance!

@reneburghardt
Copy link
Copy Markdown
Member

I'll look soonly at the changes, but one additional consistency thing came to my mind @ojasvatsyayan
Could you change all close() implementations of interpolators who are in general able to make use of memmaps to this (as in SpikesInterpolator, adjust variable names of course)?

    def close(self):
        super().close()
        # Trigger cleanup of memmap
        if hasattr(self, "spikes") and isinstance(self.spikes, np.memmap):
            _mmap_obj = getattr(self.spikes, "_mmap", None)
            if _mmap_obj is not None:
                _mmap_obj.close()
            del self.spikes

@ojasvatsyayan ojasvatsyayan force-pushed the fix-interpolator-consistency branch from 1dc88a9 to c8774fb Compare March 21, 2026 03:01
@ojasvatsyayan
Copy link
Copy Markdown
Author

@pollytur @reneburghardt Thanks for the feedback :) I’ve addressed the requested changes by aligning close() implementations across interpolators with consistent memmap cleanup.

Rebased onto the latest main, resolved conflicts, and all tests pass locally.

Happy to make any further adjustments if needed! Also, if there are other areas of the codebase that could use help or follow-up work, I’d love to take a look.

@ojasvatsyayan ojasvatsyayan force-pushed the fix-interpolator-consistency branch from ad7d3ed to b0e3d75 Compare March 23, 2026 02:43
@ojasvatsyayan ojasvatsyayan force-pushed the fix-interpolator-consistency branch from c9fb867 to 25d65f6 Compare March 24, 2026 20:16
@ojasvatsyayan
Copy link
Copy Markdown
Author

@reneburghardt @pollytur I standardized the empty-query warning message across the interpolators for consistency, updated the tests accordingly, and also deleted self.trials after ScreenInterpolator cleanup.

Copy link
Copy Markdown
Member

@reneburghardt reneburghardt left a comment

Choose a reason for hiding this comment

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

LGTM in general, but there are conflicts with the current main which need to be resolved @ojasvatsyayan Can you please do that?

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.

4 participants