From 20e2a687835fc623c89191bd189fb8b762b3eaee Mon Sep 17 00:00:00 2001 From: Moritz Huebner <moritz.huebner@ligo.org> Date: Mon, 19 Aug 2019 19:56:55 -0500 Subject: [PATCH] Added try except clause for building the lookup table --- bilby/gw/likelihood.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bilby/gw/likelihood.py b/bilby/gw/likelihood.py index 14f14b764..05c8fbcbc 100644 --- a/bilby/gw/likelihood.py +++ b/bilby/gw/likelihood.py @@ -590,7 +590,12 @@ class GravitationalWaveTransient(likelihood.Likelihood): def load_lookup_table(self, filename): if os.path.exists(filename): - loaded_file = dict(np.load(filename)) + try: + loaded_file = dict(np.load(filename)) + except AttributeError as e: + logger.warning(e) + self._create_lookup_table() + return None match, failure = self._test_cached_lookup_table(loaded_file) if match: logger.info('Loaded distance marginalisation lookup table from ' @@ -599,13 +604,10 @@ class GravitationalWaveTransient(likelihood.Likelihood): else: logger.info('Loaded distance marginalisation lookup table does ' 'not match for {}.'.format(failure)) - return None elif isinstance(filename, str): logger.info('Distance marginalisation file {} does not ' 'exist'.format(filename)) - return None - else: - return None + return None def cache_lookup_table(self): np.savez(self.cached_lookup_table_filename, -- GitLab