Skip to content

Bug in model.run_until #3327

@quaquel

Description

@quaquel

Describe the bug
There is a bug with model.run_until and model.run_for. Specifically, if you first run_for(10) and then do run_until(5.0), model.time after the second call should be 10, but is set to 5.0.

Expected behavior
Model.time should not go backward.

To Reproduce
Just add an extra check to test_schedule_run.test_already_past, asserting model.time==10

fix
The problem is that in model._advance_time, after the while loop, time is updated to until. But if until is smaller than the current value of time, we go backwards. The simplest solution is to check before the while loop if until is smaller than time and just return if true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelease notes label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions