Skip to content

Commit f4d3ce6

Browse files
committed
Set negative durations to 0 in simulation status
Will also log warnings when encountering these issues.
1 parent 325d19d commit f4d3ce6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ert/gui/model/snapshot.py

+12
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
state.COLOR_NOT_ACTIVE: QColor(*state.COLOR_NOT_ACTIVE),
7070
}
7171

72+
warn_once = True
73+
7274

7375
def _estimate_duration(
7476
start_time: datetime, end_time: datetime | None = None
@@ -429,6 +431,16 @@ def _fm_step_data(
429431
)
430432
# There is no method for truncating microseconds, so we remove them
431433
delta -= timedelta(microseconds=delta.microseconds)
434+
if delta < timedelta():
435+
global warn_once # noqa: PLW0603
436+
if warn_once:
437+
warn_once = False
438+
logger.warning(
439+
"Negative duration in snapshot encountered. "
440+
f"start_time={start_time} end_time={node.data.get(ids.END_TIME)} "
441+
f"delta={delta}"
442+
)
443+
delta = timedelta()
432444
return str(delta)
433445

434446
return node.data.get(data_name)

0 commit comments

Comments
 (0)