From a6a067be82a4e0f1e0eaa7e4620fade3f4d40a73 Mon Sep 17 00:00:00 2001
From: David Keitel <david.keitel@ligo.org>
Date: Fri, 14 Jul 2017 11:02:56 +0100
Subject: [PATCH] add SFT-vs-output timestamp check to gridsearch, and fix bug
in _get_list_of_matching_sfts
-ported check from MCMC search
-bug: for single-str SFT path, glob list comprehension
was trying every single character
---
pyfstat/core.py | 5 ++++-
pyfstat/grid_based_searches.py | 7 +++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/pyfstat/core.py b/pyfstat/core.py
index 7ee28da..0809f68 100755
--- a/pyfstat/core.py
+++ b/pyfstat/core.py
@@ -165,7 +165,10 @@ class BaseSearchClass(object):
return thetas
def _get_list_of_matching_sfts(self):
- matches = [glob.glob(p) for p in self.sftfilepath]
+ # first make sure we have a list of paths, to avoid
+ # list comprehension trying to glob each single character
+ sftfilepathlist = np.atleast_1d(self.sftfilepath)
+ matches = [glob.glob(p) for p in sftfilepathlist]
matches = [item for sublist in matches for item in sublist]
if len(matches) > 0:
return matches
diff --git a/pyfstat/grid_based_searches.py b/pyfstat/grid_based_searches.py
index 000d8ad..f33f720 100644
--- a/pyfstat/grid_based_searches.py
+++ b/pyfstat/grid_based_searches.py
@@ -106,6 +106,13 @@ class GridSearch(BaseSearchClass):
if os.path.isfile(self.out_file) is False:
logging.info('No old data found, continuing with grid search')
return False
+ if self.sftfilepath is not None:
+ oldest_sft = min([os.path.getmtime(f) for f in
+ self._get_list_of_matching_sfts()])
+ if os.path.getmtime(self.out_file) < oldest_sft:
+ logging.info('Search output data outdates sft files,'
+ + ' continuing with grid search')
+ return False
data = np.atleast_2d(np.genfromtxt(self.out_file, delimiter=' '))
if np.all(data[:, 0:-1] == self.input_data):
logging.info(
--
GitLab