Skip to content

Commit

Permalink
addressing eneko's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rogersamso authored and enekomartinmartinez committed Aug 1, 2023
1 parent 02c3c06 commit 507e401
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 4 additions & 4 deletions pysd/py_backend/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 507e401

Please sign in to comment.