Skip to content

Commit

Permalink
Added dt parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
tcstewar committed May 30, 2018
1 parent 6b0c8d1 commit 926f456
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion nengo_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def main():
parser.add_argument(
'-b', '--backend', metavar='BACKEND',
default='nengo', type=str, help='default backend to use')
parser.add_argument(
'--dt', metavar='DT', default=0.001, type=float,
help='simulator time step in seconds (default: 0.001)')
parser.add_argument('--browser', dest='browser', type=str,
metavar='BROWSER', default=True,
help=browser_help)
Expand Down Expand Up @@ -97,7 +100,8 @@ def main():
nengo_gui.__path__[0], 'examples', 'default.py')
else:
filename = args.filename
page_settings = nengo_gui.page.PageSettings(backend=args.backend)
page_settings = nengo_gui.page.PageSettings(backend=args.backend,
dt=args.dt)
s = None
while s is None:
try:
Expand Down
12 changes: 8 additions & 4 deletions nengo_gui/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@


class PageSettings(object):
__slots__ = ['backend', 'editor_class', 'filename_cfg']
__slots__ = ['backend', 'editor_class', 'filename_cfg', 'dt']

def __init__(
self, filename_cfg=None, backend='nengo',
self, filename_cfg=None, backend='nengo', dt=0.001,
editor_class=nengo_gui.components.AceEditor):
self.filename_cfg = filename_cfg
self.backend = backend
self.editor_class = editor_class
self.dt = dt


class Page(object):
Expand Down Expand Up @@ -465,6 +466,8 @@ def build(self):
old_sim.sim = None
old_sim.finished = True

dt = self.settings.dt

exec_env = nengo_gui.exec_env.ExecutionEnvironment(self.filename,
allow_sim=True)
handles_progress = ('progress_bar' in
Expand All @@ -474,9 +477,10 @@ def build(self):
with exec_env:
if handles_progress:
self.sim = backend.Simulator(
self.model, progress_bar=self.locals['_viz_progress'])
self.model, dt=dt,
progress_bar=self.locals['_viz_progress'])
else:
self.sim = backend.Simulator(self.model)
self.sim = backend.Simulator(self.model, dt=dt)

except:
line = nengo_gui.exec_env.determine_line_number()
Expand Down

0 comments on commit 926f456

Please sign in to comment.