Skip to content

Commit

Permalink
Merge pull request #454 from jgonin/issue67
Browse files Browse the repository at this point in the history
Issue67 (Move the `max_delay` argument of `setup()` into `extra_params`)
  • Loading branch information
apdavison committed Apr 25, 2017
2 parents 76b2d02 + f825ab1 commit 74ee428
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 18 deletions.
6 changes: 4 additions & 2 deletions pyNN/brian/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ def list_standard_models():


def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
max_delay=DEFAULT_MAX_DELAY, **extra_params):
**extra_params):
"""
Should be called at the very beginning of a script.
extra_params contains any keyword arguments that are required by a given
simulator but not by others.
"""
common.setup(timestep, min_delay, max_delay, **extra_params)

max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
common.setup(timestep, min_delay, **extra_params)
simulator.state.clear()
brian.set_global_preferences(**extra_params)
simulator.state.dt = timestep # move to common.setup?
Expand Down
3 changes: 2 additions & 1 deletion pyNN/common/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self):


def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
max_delay=DEFAULT_MAX_DELAY, **extra_params):
**extra_params):
"""
Initialises/reinitialises the simulator. Any existing network structure is
destroyed.
Expand All @@ -41,6 +41,7 @@ def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
`extra_params` contains any keyword arguments that are required by a given
simulator but not by others.
"""
max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
invalid_extra_params = ('mindelay', 'maxdelay', 'dt', 'time_step')
for param in invalid_extra_params:
if param in extra_params:
Expand Down
1 change: 1 addition & 0 deletions pyNN/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ def projection(self, projection):

def __call__(self, i, j):
raise NotImplementedError

6 changes: 4 additions & 2 deletions pyNN/mock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def list_standard_models():


def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
max_delay=DEFAULT_MAX_DELAY, **extra_params):
common.setup(timestep, min_delay, max_delay, **extra_params)
**extra_params):

max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
common.setup(timestep, min_delay, **extra_params)
simulator.state.clear()
simulator.state.dt = timestep # move to common.setup?
simulator.state.min_delay = min_delay
Expand Down
5 changes: 3 additions & 2 deletions pyNN/moose/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
# ==============================================================================


def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
def setup(timestep=0.1, min_delay=0.1, **extra_params):
"""
Should be called at the very beginning of a script.
extra_params contains any keyword arguments that are required by a given
simulator but not by others.
"""
common.setup(timestep, min_delay, max_delay, **extra_params)
max_delay = extra_params.get('max_delay', 10.0)
common.setup(timestep, min_delay, **extra_params)
simulator.state.dt = timestep
if not os.path.exists(temporary_directory):
os.mkdir(temporary_directory)
Expand Down
5 changes: 3 additions & 2 deletions pyNN/nemo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def list_standard_models():
# ==============================================================================


def setup(timestep=1, min_delay=1, max_delay=10.0, **extra_params):
def setup(timestep=1, min_delay=1, **extra_params):
"""
Should be called at the very beginning of a script.
extra_params contains any keyword arguments that are required by a given
Expand All @@ -52,7 +52,8 @@ def setup(timestep=1, min_delay=1, max_delay=10.0, **extra_params):
if (min_delay < 1):
raise Exception("It is not currently possible to have a min_delay less than 1ms with this simulator")

common.setup(timestep, min_delay, max_delay, **extra_params)
max_delay = extra_params.get('max_delay', 10.0)
common.setup(timestep, min_delay, **extra_params)
simulator.state = simulator._State(timestep, min_delay, max_delay)
simulator.spikes_array_list = []
simulator.recorder_list = []
Expand Down
5 changes: 3 additions & 2 deletions pyNN/nest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _discrepancy_due_to_rounding(parameters, output_values):


def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
max_delay=DEFAULT_MAX_DELAY, **extra_params):
**extra_params):
"""
Should be called at the very beginning of a script.
Expand All @@ -110,7 +110,8 @@ def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
`rng_seeds_seed`:
a single seed that will be used to generate random values for `rng_seeds`
"""
common.setup(timestep, min_delay, max_delay, **extra_params)
max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
common.setup(timestep, min_delay, **extra_params)
simulator.state.clear()
for key in ("verbosity", "spike_precision", "recording_precision",
"threads"):
Expand Down
7 changes: 3 additions & 4 deletions pyNN/neuron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def list_standard_models():
# ==============================================================================


def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
max_delay=DEFAULT_MAX_DELAY, **extra_params):
def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY, **extra_params):
"""
Should be called at the very beginning of a script.
Expand All @@ -72,12 +71,12 @@ def setup(timestep=DEFAULT_TIMESTEP, min_delay=DEFAULT_MIN_DELAY,
returns: MPI rank
"""
common.setup(timestep, min_delay, max_delay, **extra_params)
common.setup(timestep, min_delay, **extra_params)
simulator.initializer.clear()
simulator.state.clear()
simulator.state.dt = timestep
simulator.state.min_delay = min_delay
simulator.state.max_delay = max_delay
simulator.state.max_delay = extra_params.get('max_delay', DEFAULT_MAX_DELAY)
if 'use_cvode' in extra_params:
simulator.state.cvode.active(int(extra_params['use_cvode']))
if 'rtol' in extra_params:
Expand Down
6 changes: 3 additions & 3 deletions pyNN/nineml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def list_standard_models():
return [obj.__name__ for obj in globals().values() if isinstance(obj, type) and issubclass(obj, std.StandardCellType)]


def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params):
common.setup(timestep, min_delay, max_delay, **extra_params)
def setup(timestep=0.1, min_delay=0.1, **extra_params):
common.setup(timestep, min_delay, **extra_params)
simulator.state.clear()
simulator.state.dt = timestep # move to common.setup?
simulator.state.min_delay = min_delay
simulator.state.max_delay = max_delay
simulator.state.max_delay = extra_params.get('max_delay', 10.0)
simulator.state.mpi_rank = extra_params.get('rank', 0)
simulator.state.num_processes = extra_params.get('num_processes', 1)
simulator.state.output_filename = extra_params.get("filename", "PyNN29ML.xml")
Expand Down

0 comments on commit 74ee428

Please sign in to comment.