Skip to content

Commit

Permalink
remove duplicate arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
1b15 committed Mar 5, 2024
1 parent 69d6aab commit 6436e20
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
16 changes: 5 additions & 11 deletions neurolib/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,10 @@ def initializeRun(self, initializeBold=False):

def run(
self,
inputs=None,
chunkwise=False,
chunksize=None,
bold=False,
append=False,
append_outputs=None,
append_outputs=False,
continue_run=False,
):
"""
Expand All @@ -204,15 +202,11 @@ def run(
:type chunksize: int, optional
:param bold: simulate BOLD signal (only for chunkwise integration), defaults to False
:type bold: bool, optional
:param append: append the chunkwise outputs to the outputs attribute, defaults to False. Note: BOLD outputs are always appended
:type append: bool, optional
:param append_outputs: append new and chunkwise outputs to the outputs attribute, defaults to False. Note: BOLD outputs are always appended
:type append_outputs: bool, optional
:param continue_run: continue a simulation by using the initial values from a previous simulation
:type continue_run: bool
"""
# TODO: legacy argument support
if append_outputs is not None:
append = append_outputs

self.initializeRun(initializeBold=bold)

# if a previous run is not to be continued clear the model's state
Expand All @@ -225,7 +219,7 @@ def run(
chunkwise = chunkwise if chunksize is None else True

if chunkwise is False:
self.integrate(append_outputs=append, simulate_bold=bold)
self.integrate(append_outputs=append_outputs, simulate_bold=bold)

else:
if chunksize is None:
Expand All @@ -235,7 +229,7 @@ def run(
# and whether sampling_dt is compatible with duration and chunksize
self.checkChunkwise(chunksize)

self.integrateChunkwise(chunksize=chunksize, bold=bold, append_outputs=append)
self.integrateChunkwise(chunksize=chunksize, bold=bold, append_outputs=append_outputs)

# check if there was a problem with the simulated data
self.checkOutputs()
Expand Down
11 changes: 3 additions & 8 deletions neurolib/models/multimodel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,12 @@ def run(
chunkwise=False,
chunksize=None,
bold=False,
append=False,
append_outputs=None,
append_outputs=False,
continue_run=False,
noise_input=None,
):
self._update_model_params()

# TODO: legacy argument support
if append_outputs is not None:
append = append_outputs

# if a previous run is not to be continued clear the model's state
if continue_run:
self.setInitialValuesToLastState()
Expand All @@ -146,7 +141,7 @@ def run(
self.initializeRun(initializeBold=bold)

if chunkwise is False:
self.integrate(append_outputs=append, simulate_bold=bold, noise_input=noise_input)
self.integrate(append_outputs=append_outputs, simulate_bold=bold, noise_input=noise_input)

else:
if chunksize is None:
Expand All @@ -156,7 +151,7 @@ def run(
if bold and not self.boldInitialized:
logging.warn(f"{self.name}: BOLD model not initialized, not simulating BOLD. Use `run(bold=True)`")
bold = False
self.integrateChunkwise(chunksize=chunksize, bold=bold, append_outputs=append)
self.integrateChunkwise(chunksize=chunksize, bold=bold, append_outputs=append_outputs)

# check if there was a problem with the simulated data
self.checkOutputs()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_autochunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def single_node_test(self, model):
# chunkwise run
m2 = model()
m2.params = pars_bak.copy()
m2.run(chunkwise=True, chunksize=chunksize, append=True)
m2.run(chunkwise=True, chunksize=chunksize, append_outputs=True)
# check
self.assertTupleEqual(m1.output.shape, m2.output.shape)
difference = np.sum(np.abs(m1.output - m2.output))
Expand All @@ -61,7 +61,7 @@ def network_test(self, model):
# chunkwise run
m2 = model(Cmat=ds.Cmat, Dmat=ds.Dmat)
m2.params = pars_bak.copy()
m2.run(chunkwise=True, chunksize=chunksize, append=True)
m2.run(chunkwise=True, chunksize=chunksize, append_outputs=True)
# check
self.assertTupleEqual(m1.output.shape, m2.output.shape)
difference = np.sum(np.abs(m1.output - m2.output))
Expand Down

0 comments on commit 6436e20

Please sign in to comment.