Skip to content

Commit

Permalink
Make the use of the name argument in GroupCodeRunner consistent with …
Browse files Browse the repository at this point in the history
…the rest of the code.
  • Loading branch information
mstimberg committed Jun 12, 2013
1 parent 1de9c14 commit 4eb02ff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion brian2/groups/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class GroupCodeRunner(BrianObject):
def __init__(self, group, template, code=None, iterate_all=True,
when=None, name='coderunner*', check_units=True,
additional_specifiers=None):
BrianObject.__init__(self, when=when, name=group.name+'_'+name)
BrianObject.__init__(self, when=when, name=name)
self.group = weakref.proxy(group)
self.template = template
self.abstract_code = code
Expand Down
17 changes: 11 additions & 6 deletions brian2/groups/neurongroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, group, method):
GroupCodeRunner.__init__(self, group,
group.language.template_state_update,
when=(group.clock, 'groups'),
name='stateupdater*',
name=group.name+'_stateupdater*',
check_units=False)

self.method = StateUpdateMethod.determine_stateupdater(self.group.equations,
Expand Down Expand Up @@ -73,7 +73,7 @@ def __init__(self, group):
GroupCodeRunner.__init__(self, group,
group.language.template_threshold,
when=(group.clock, 'thresholds'),
name='thresholder*',
name=group.name+'_thresholder*',
# TODO: This information should be included in
# the template instead
additional_specifiers=['t',
Expand All @@ -97,7 +97,7 @@ def __init__(self, group):
GroupCodeRunner.__init__(self, group,
group.language.template_reset,
when=(group.clock, 'resets'),
name='resetter*',
name=group.name+'_resetter*',
iterate_all=False,
additional_specifiers=['_spikes'])

Expand Down Expand Up @@ -272,7 +272,7 @@ def _allocate_memory(self, dtype=None):
return arrays


def runner(self, code, when=None, name='runner*'):
def runner(self, code, when=None, name=None):
'''
Returns a `CodeRunner` that runs abstract code in the groups namespace
Expand All @@ -284,14 +284,19 @@ def runner(self, code, when=None, name='runner*'):
When to run, by default in the 'start' slot with the same clock as
the group.
name : str, optional
A unique name, by default the name of the group appended with
'runner', 'runner_1', etc.
A unique name, if non is given the name of the group appended with
'runner', 'runner_1', etc. will be used. If a name is given
explicitly, it will be used as given (i.e. the group name will not
be prepended automatically).
'''
if when is None: # TODO: make this better with default values
when = Scheduler(clock=self.clock)
else:
raise NotImplementedError

if name is None:
name = self.name + '_runner*'

runner = GroupCodeRunner(self, self.language.template_state_update,
code=code, name=name, when=when)
return runner
Expand Down

0 comments on commit 4eb02ff

Please sign in to comment.