From 1ecc0e5efeddeb98557096bae2215e6cf52a6f23 Mon Sep 17 00:00:00 2001 From: mstimberg Date: Thu, 11 Jul 2013 19:06:38 +0200 Subject: [PATCH] Only do the output reporting if a report argument was given (regardless what was given, at the moment) --- brian2/core/network.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/brian2/core/network.py b/brian2/core/network.py index c0698922d..a4c95ea06 100644 --- a/brian2/core/network.py +++ b/brian2/core/network.py @@ -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() @@ -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):