Fix silent fail on pset sampling when time is NaN - #2823
Merged
erikvansebille merged 4 commits intoAug 17, 2026
Merged
Conversation
Comment on lines
+396
to
+398
| if np.any(np.isnan(t)): | ||
| nan_indices = np.where(np.isnan(t))[0] | ||
| raise ValueError(f"Time values for particles with indices {nan_indices} cannot be NaN.") |
Contributor
There was a problem hiding this comment.
Wondering whether this should be somewhere in the execute loop?
i.e., make sure that the time for each particle is set before we go into the main loop
Is there a usecase of t being nan during execution?
Member
Author
There was a problem hiding this comment.
No, the point is that time is never NaN in a pset.execute (see here), but it can be before the execute loop; e.g. during an initial sampling (particles.var = fieldset.var[particles]). That is why we need this error here and not in the execute loop
erikvansebille
enabled auto-merge (squash)
August 17, 2026 10:15
VeckoTheGecko
approved these changes
Aug 17, 2026
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.
Description
This PR fixes #2822, where field interpolation would silently fail if the
particles.tincluded NaN values. Now, this raises a ValueErrorChecklist
mainfor normal development,v3-supportfor v3 support)AI Disclosure
None