diff --git a/docs/advanced_usage.rst b/docs/advanced_usage.rst index df406743..0c8f7756 100644 --- a/docs/advanced_usage.rst +++ b/docs/advanced_usage.rst @@ -7,10 +7,10 @@ Running models one (or more) step(s) at a time ---------------------------------------------- Coupling different models requires the exchange of certain variables between them. This is only possible if a stepping mechanism is available, which allows for running any number of steps with certain boundary conditions that evolve along time. -In this section, we show how the teacup model may be run in a for loop using the :py:meth:`.step` function (rather than the :py:meth:`.run` function) and update the value of a model variable before each step:: +In this section, we show how the teacup model may be run in a for loop using the :py:meth:`pysd.py_backend.model.Model.step` function (rather than the :py:meth:`pysd.py_backend.model.Model.run` function) and update the value of a model variable before each step:: from pysd.py_backend.output import ModelOutput - + # instantiate ModelOutput object output = ModelOutput() diff --git a/pysd/py_backend/model.py b/pysd/py_backend/model.py index bfaf9d8d..e43cb3e5 100644 --- a/pysd/py_backend/model.py +++ b/pysd/py_backend/model.py @@ -1312,7 +1312,6 @@ def __init__(self, py_model_file, data_files, initialize, missing_values): self.missing_values = missing_values self.progress = None self.output = None - self._stepper_mode = False if initialize: self.initialize() @@ -1420,6 +1419,8 @@ def run(self, params=None, return_columns=None, return_timestamps=None, pysd.set_initial_condition : handles setting initial conditions """ + self._stepper_mode = False + if reload: self.reload() @@ -1440,7 +1441,6 @@ def set_stepper(self, output_obj, params=None, step_vars=[], return_columns=None, return_timestamps=None, initial_condition='original', final_time=None, time_step=None, saveper=None, cache_output=True): - """ Configure the model stepping behavior. @@ -1460,7 +1460,7 @@ def set_stepper(self, output_obj, params=None, step_vars=[], List of variable or parameter names whose values might be updated after one or more simulation steps. - return_columns:list, 'step' or None (optional) + return_columns: list, 'step' or None (optional) List of string model component names, returned dataframe will have corresponding columns. If 'step' only variables with cache step will be returned. If None, variables with cache step @@ -1564,7 +1564,7 @@ def _config_simulation(self, params, return_columns, return_timestamps, if self._stepper_mode: for step_var in kwargs["step_vars"]: - self.dependencies[step_var]["time"] = 1 + self._dependencies[step_var]["time"] = 1 # update cache types after setting params self._assign_cache_type()