FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Schedule events resolve at the scheduled time, not a step early by milanofthe · Pull Request #248 · pathsim/pathsim · GitHub

Schedule events resolve at the scheduled time, not a step early - #248

Merged
milanofthe merged 1 commit into
masterfrom
fix/schedule-close-ratio
Aug 12, 2026
Merged

Schedule events resolve at the scheduled time, not a step early#248
milanofthe merged 1 commit into
masterfrom
fix/schedule-close-ratio

Conversation

Copy link
Copy Markdown
Member

A Schedule or ScheduleList under a fixed timestep resolves up to one full dt before the time it was asked for.

Schedule(t_start=0.05, t_period=0.1) with dt=0.01 fires at 0.04, 0.15, 0.24, 0.35 instead of 0.05, 0.15, 0.25, 0.35. ScheduleList(times_evt=[0.07, 0.13, 0.29]) fires at 0.06, 0.13, 0.29. Which entries slip depends on how the accumulated step time rounds, so it is intermittent rather than a constant offset.

detect(t) is called with t at the end of the step, and the fixed-step branch resolves at self.time + ratio * dt — ratio is a position within the step, 0 at its start and 1 at its end. When the schedule sits exactly on t, both detect methods return ratio = 0.0, placing the event at the start of the step: a whole dt early.

Both return 1.0 now. ZeroCrossing already used that convention for its own exact-hit case (return True, True, 1.0), so this makes the two event families agree.

The other close branch (_t >= t_next, the event was already passed) keeps 0.0 — there the event really does belong at the start of the step.

Only the fixed-step path is affected. The adaptive branch resolves close events at time_dt and ignores ratio, so nothing changes there beyond the ordering in _detected_events, which is sorted by ratio and now reflects the actual order.

TestWrapper.test_trigger_event asserted the old literal and is updated. Added coverage: the exact-hit ratio for both classes, and an end-to-end check that a schedule off the step grid fires at the requested times (to 1e-12).

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

milanofthe merged commit 878ebdf into master Aug 12, 2026
4 checks passed
milanofthe deleted the fix/schedule-close-ratio branch August 12, 2026 15:17
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL