From 97bd582cf7746dc42f478880aa941cf6aa9c08a6 Mon Sep 17 00:00:00 2001 From: Maximilian Soelch Date: Wed, 2 Sep 2015 11:51:07 +0200 Subject: [PATCH 1/3] adjusted TimeElapsed for interruptions previously, TimeElapsed would simply calculate time from its instantiation, which is problematic if the experiment is interrupted thereafter. Now it can read out the info dict which can hold a more meaningful runtime value. --- climin/stops/stops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/climin/stops/stops.py b/climin/stops/stops.py index 84a6317..5a248c4 100644 --- a/climin/stops/stops.py +++ b/climin/stops/stops.py @@ -147,7 +147,7 @@ def __init__(self, sec): self.start = time.time() def __call__(self, info): - return time.time() - self.start > self.sec + return info.get('time', time.time()) - self.start > self.sec def All(criterions): From 6b3124a0eafa366a11304ba4939bfff1c1a687dc Mon Sep 17 00:00:00 2001 From: Maximilian Soelch Date: Fri, 11 Sep 2015 12:20:25 +0200 Subject: [PATCH 2/3] another fix of stopping --- climin/stops/stops.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/climin/stops/stops.py b/climin/stops/stops.py index 5a248c4..6c584b2 100644 --- a/climin/stops/stops.py +++ b/climin/stops/stops.py @@ -147,7 +147,10 @@ def __init__(self, sec): self.start = time.time() def __call__(self, info): - return info.get('time', time.time()) - self.start > self.sec + if 'runtime' in info: + return info['runtime'] > self.sec + else: + return time.time() - self.start > self.sec def All(criterions): From 74f142937adde15ff1054851c2b410f1d33f4f21 Mon Sep 17 00:00:00 2001 From: Maximilian Soelch Date: Sat, 26 Sep 2015 18:56:46 +0200 Subject: [PATCH 3/3] added documentation for new usage --- climin/stops/stops.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/climin/stops/stops.py b/climin/stops/stops.py index 6c584b2..883f87e 100644 --- a/climin/stops/stops.py +++ b/climin/stops/stops.py @@ -132,6 +132,10 @@ class TimeElapsed(object): >>> time.sleep(0.5) >>> stop({}) True + >>> stop2 = S.TimeElapsed(10); stop2({'runtime': 9}) + False + >>> stop3 = S.TimeElapsed(10); stop2({'runtime': 11}) + True """ def __init__(self, sec):