From 4b09136fc1cc8cf2acc86edf72e674c52a07cc57 Mon Sep 17 00:00:00 2001 From: Tomasz Baka <tomasz.baka@ligo.org> Date: Wed, 17 Aug 2022 12:26:22 +0000 Subject: [PATCH] Fix cashe reading error --- AUTHORS.md | 3 ++- bilby/gw/conversion.py | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 42d22edbc..a1a3176a7 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -75,7 +75,8 @@ Stephen R Green Sumeet Kulkarni Sylvia Biscoveanu Tathagata Ghosh +Tomasz Baka Virginia d'Emilio Vivien Raymond Ka-Lok Lo -Isaac Legred \ No newline at end of file +Isaac Legred diff --git a/bilby/gw/conversion.py b/bilby/gw/conversion.py index 46e912710..c3640abd3 100644 --- a/bilby/gw/conversion.py +++ b/bilby/gw/conversion.py @@ -1479,11 +1479,15 @@ def generate_posterior_samples_from_marginalized_likelihood( use_cache = False if use_cache and os.path.exists(cache_filename) and not command_line_args.clean: - with open(cache_filename, "rb") as f: - cached_samples_dict = pickle.load(f) + try: + with open(cache_filename, "rb") as f: + cached_samples_dict = pickle.load(f) + except EOFError: + logger.warning("Cache file is empty") + cached_samples_dict = None # Check the samples are identical between the cache and current - if cached_samples_dict["_samples"].equals(samples): + if (cached_samples_dict is not None) and (cached_samples_dict["_samples"].equals(samples)): # Calculate reconstruction percentage and print a log message nsamples_converted = np.sum( [len(val) for key, val in cached_samples_dict.items() if key != "_samples"] -- GitLab