Improve support for missingness in Filters/Smoothers#235
Open
mattlevine22 wants to merge 4 commits into
Open
Conversation
DanWaxman
requested changes
May 21, 2026
Comment on lines
+29
to
+44
| def _raise_if_missing_detected( | ||
| obs_values: Real[Array, "*obs_value_plate obs_time observation_dim"] | ||
| | Real[Array, "*obs_value_plate obs_time"], | ||
| has_missing, | ||
| message: str, | ||
| ) -> None: | ||
| """Raise plainly when possible; fall back to eqx.error_if under tracing.""" | ||
| try: | ||
| missing_now = bool(has_missing) | ||
| except jax.errors.TracerBoolConversionError: | ||
| _ = eqx.error_if(obs_values, has_missing, message) | ||
| return | ||
|
|
||
| if missing_now: | ||
| raise ValueError(message) | ||
|
|
Collaborator
There was a problem hiding this comment.
This feels weird as a separate helper function. I understand it does the tracing thing, but that is much more general as helper.
Collaborator
Author
There was a problem hiding this comment.
ok, generalized it (and allow warning, which codex says can't have the same except trick)
Comment on lines
+235
to
+236
| Does not support missing observations (data cannot have NaNs). | ||
|
|
Collaborator
There was a problem hiding this comment.
I don't think this is strictly true; it's up to the user to specify transition and observation functions that work okay with NaNs, though.
Collaborator
Author
There was a problem hiding this comment.
okay, I have PF do a warning, and changed the docstring to explain what you said.
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.
This PR adds early missing-observation validation for filtering and smoothing, documents missingness support directly on the filter/smoother config classes, and stabilizes the continuous-time hierarchical simulator/discretizer smoke fixtures so they no longer generate accidental
NaNrollouts. Unsupported missing-observation paths now fail early with clear messages: cuthbertKFConfig,EnKFConfig, andKFSmootherConfigremain the supported discrete-timeNaNpaths, while cuthbertEKF/EKFSmootherand CD-Dynamax filter/smoother paths are rejected cleanly.It also adds missing-observation regression coverage in tests/test_missing_observations.py, updates the filter/smoother config docs in dynestyx/inference/filter_configs.py and dynestyx/inference/smoother_configs.py to state whether each backend supports missing observations via
NaNs, and includes the new 11_missing_observations.ipynb tutorial in the docs navigation via mkdocs.yml.