Add init_state arg to filtering API#264
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an init_state optional argument to the offline filtering APIs (standard and factorial) to support batched filtering that starts from a caller-provided initial state, aligning with the direction discussed in #253 without removing init_prepare.
Changes:
- Extend
cuthbert.filterandcuthbert.factorial.filterto accept an optionalinit_stateand adjust expectedmodel_inputslength accordingly. - Update filtering implementations to skip
init_preparewhen an initial state is supplied. - Add/adjust tests to exercise filtering behavior when
init_stateis provided.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
cuthbert/filtering.py |
Adds init_state to the unified filtering API and updates the prep flow accordingly. |
cuthbert/factorial/filtering.py |
Adds init_state support to factorial filtering and updates the initialization path. |
tests/cuthbert/gaussian/test_kalman.py |
Adds coverage for providing init_state to the standard filter (seq + parallel). |
tests/cuthbert/factorial/test_kalman.py |
Adds coverage for providing init_state to factorial filtering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sahel13
left a comment
There was a problem hiding this comment.
This looks good. Since this is a user-facing change, one minor question is whether we should make the arguments that have defaults in cuthbert.filter keyword-only, so that users that currently use filter(obj, inputs, False, key) would get a clear error.
Good idea, I like this! |
|
@Sahel13 I made the args after |
|
Yup this is it! |
|
As this is a user-facing change, it would be good to get @AdrienCorenflos' thoughts too |
As discussed in #253
This allows batched filtering starting from a specified
init_state.This adds the support without the major refactor that would be needed if we were to remove
init_preparefromcuthbert.filterentirely (which is arguably cleaner: less code, no optional arg but slightly more load on the user).