Fix: prevent duplicate exports by popping matched time in is_it_time_…#1073
Merged
RemDelaporteMathurin merged 3 commits intofestim-dev:fenicsxfrom Feb 23, 2026
Merged
Conversation
…to_export This updates `is_it_time_to_export` so that when a timestep matches a desired export time (within the `np.isclose` tolerances), the corresponding entry in `times` is popped. Previously, multiple consecutive timesteps within the tolerance window could all trigger `True`, leading to repeated exports for the same target time, especially at high simulation times where the relative tolerance (rtol) allows larger absolute differences. With this change: - only the first matching timestep triggers an export - the matched time is removed, preventing any subsequent exports for it This ensures a 1-to-1 mapping between requested and actual exports, provided the simulation reaches timesteps sufficiently close to the target times.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fenicsx #1073 +/- ##
========================================
Coverage 94.77% 94.77%
========================================
Files 44 44
Lines 3174 3175 +1
========================================
+ Hits 3008 3009 +1
Misses 166 166 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
RemDelaporteMathurin
approved these changes
Feb 23, 2026
b09927e
into
festim-dev:fenicsx
10 of 11 checks passed
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
Summary
This PR updates
is_it_time_to_exportso that when a timestep matches a desired export time (within thenp.isclosetolerances), the corresponding entry intimesis popped. This prevents repeated exports for the same target time.Example:
Related Issues
Motivation and Context
Previously, multiple consecutive timesteps inside the tolerance window could all return
True, causing repeated exports for a single requested export time, especially at high simulation times where the relative tolerance (rtol) allows larger absolute differences. This change ensures a 1‑to‑1 mapping between requested and actual exports, provided the simulation reaches timesteps sufficiently close to the target times.Type of Change
Testing
pytest)Code Quality Checklist
ruff format .)ruff check .)Documentation
Breaking Changes
Screenshots/Examples
Additional Notes
Even though duplicates are now removed, very large simulation times can still cause the matched timestep to be several seconds away from the desired export time. Exposing tolerances (e.g. reducing
rtol) cannot fully solve this issue: tighteningrtolonly delays it and may prevent matching early in the simulation, while relying on a smallatolmay fail when the timestep becomes larger near an export event.If precise export timings are required, one way to mitigate this limitation is to use a small
atoland ensure that the desired export times are included in the solver’s milestones so that the simulation visits them closely enough.