Skip to content

Commit

Permalink
Only do the output reporting if a report argument was given (regardle…
Browse files Browse the repository at this point in the history
…ss what was given, at the moment)
  • Loading branch information
mstimberg committed Jul 11, 2013
1 parent a8f3ec3 commit 1ecc0e5
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions brian2/core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,19 +345,21 @@ def run(self, duration, report=None, report_period=60*second,

# Find the first clock to be updated (see note below)
clock, curclocks = self._nextclocks()
start = time.time()
next_report_time = start + 10
if report is not None:
start = current = time.time()
next_report_time = start + 10
while clock.running and not self._stopped and not Network._globally_stopped:
# update the network time to this clocks time
self.t_ = clock.t_
current = time.time()
if current > next_report_time:
report = '{t} simulated ({percent}%), estimated {remaining} s remaining.'
remaining = int(round((current - start)/self.t*(duration-self.t)))
print report.format(t=self.t, percent=int(round(100*self.t/duration)),
remaining=remaining)
next_report_time = current + 10
# update the objects with this clock
if report is not None:
current = time.time()
if current > next_report_time:
report_msg = '{t} simulated ({percent}%), estimated {remaining} s remaining.'
remaining = int(round((current - start)/self.t*(duration-self.t)))
print report_msg.format(t=self.t, percent=int(round(100*self.t/duration)),
remaining=remaining)
next_report_time = current + 10
# update the objects with this clock
for obj in self.objects:
if obj.clock in curclocks and obj.active:
obj.update()
Expand All @@ -371,7 +373,9 @@ def run(self, duration, report=None, report_period=60*second,
clock, curclocks = self._nextclocks()

self.t = t_end


if report is not None:
print 'Took ', current-start, 's in total.'
self.post_run()

def stop(self):
Expand Down

0 comments on commit 1ecc0e5

Please sign in to comment.