Skip to content

Commit

Permalink
correct emit_time for the global_time_precision to avoid floating poi…
Browse files Browse the repository at this point in the history
…nt rounding errors
  • Loading branch information
eagmon committed Feb 21, 2024
1 parent 58f7a84 commit d9e5815
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vivarium/core/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,8 @@ def run_for(
"""
end_time = self.global_time + interval
emit_time = self.global_time + self.emit_step
if self.global_time_precision is not None:
emit_time = round(emit_time, self.global_time_precision)

while self.global_time < end_time or force_complete:
full_step = math.inf
Expand Down Expand Up @@ -1024,6 +1026,8 @@ def run_for(
while emit_time <= self.global_time:
self._emit_store_data()
emit_time += self.emit_step
if self.global_time_precision is not None:
emit_time = round(emit_time, self.global_time_precision)

else:
# all processes have run past the interval
Expand Down

0 comments on commit d9e5815

Please sign in to comment.