add next_scheduled_time property to EventGenerator#3423
Merged
Conversation
|
Performance benchmarks:
|
quaquel
reviewed
Mar 3, 2026
mesa/time/events.py
Outdated
| return self._current_event.time | ||
|
|
||
| @property | ||
| def is_scheduled(self) -> bool: |
Member
There was a problem hiding this comment.
is this not redundant with is_active?
Contributor
Author
There was a problem hiding this comment.
you're right it slipped my mind, they are redundant. i'll remove is_scheduled
quaquel
reviewed
Mar 3, 2026
mesa/time/events.py
Outdated
| return self._execution_count | ||
|
|
||
| @property | ||
| def next_time(self) -> float | None: |
Member
There was a problem hiding this comment.
Suggested change
| def next_time(self) -> float | None: | |
| def next_scheduled_time(self) -> float | None: |
55d8d61 to
4545145
Compare
quaquel
approved these changes
Mar 4, 2026
Member
|
96c1191 to
4c0aa26
Compare
Contributor
Author
|
thanks for the review, i've updated the PR title, description and tests. |
Member
|
@quaquel feel free to (also) tag me as a reviewer on time / event PRs. |
42 tasks
EwoutH
pushed a commit
that referenced
this pull request
Mar 15, 2026
* add next_time and is_scheduled properties to EventGenerator * changed property name * improved tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
EwoutH
pushed a commit
that referenced
this pull request
Mar 15, 2026
* add next_time and is_scheduled properties to EventGenerator * changed property name * improved tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.
Summary
This PR adds a property
next_scheduled_timeto EventGenerator. It exposes the time of the next scheduled execution, or None if no event is currently scheduled.Part of the event generator improvements in #3420.
Motive
Currently there is no simple way to inspect when an EventGenerator will execute next without accessing internal attributes such as
_current_event. For debugging, monitoring, or higher-level scheduling logic it is useful to know when the next execution is scheduled. This change exposes that information through a small explicit public API.Implementation
A new read-only property
next_scheduled_timewas added to EventGenerator. It returns the time of the currently scheduled event and None when no event is scheduled. It relies on the existing internal_current_eventstate.Usage Examples