Skip to content

Commit 76229a5

Browse files
EwoutHtpike3
authored andcommitted
DiscreteEventScheduler: Clean up docstring a bit
1 parent 6dd6c16 commit 76229a5

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

mesa/time.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,8 @@ def schedule_event(self, time: TimeT, agent: Agent) -> None:
385385
raise ValueError(
386386
f"Scheduled time ({time}) must be >= the current time ({self.time})"
387387
)
388-
event = (
389-
time,
390-
self.model.random.random(),
391-
agent,
392-
) # Add a random value for secondary sorting
388+
# Create an event, sorted first on time, secondary on a random value
389+
event = (time, self.model.random.random(), agent)
393390
heapq.heappush(self.event_queue, event)
394391

395392
def schedule_in(self, delay: TimeT, agent: Agent) -> None:
@@ -404,10 +401,8 @@ def step(self) -> None:
404401
end_time = self.time + self.time_step
405402

406403
while self.event_queue and self.event_queue[0][0] <= end_time:
407-
# Get the next event
408-
time, _, agent = heapq.heappop(
409-
self.event_queue
410-
) # Ignore the random value during unpacking
404+
# Get the next event (ignore the random value during unpacking)
405+
time, _, agent = heapq.heappop(self.event_queue)
411406

412407
# Advance time to the event's time
413408
self.time = time

0 commit comments

Comments
 (0)