Skip to content

Commit

Permalink
Warn for KeyError in get_decompressed_waveform
Browse files Browse the repository at this point in the history
  • Loading branch information
GarethCabournDavies committed Jan 16, 2025
1 parent fb5bbc3 commit 1d3ac81
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pycbc/waveform/bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import pycbc.io
from pycbc.io.ligolw import LIGOLWContentHandler
import hashlib
import warnings


def sigma_cached(self, psd):
Expand Down Expand Up @@ -782,7 +783,14 @@ def generate_with_delta_f_and_max_freq(self, t_num, max_freq, delta_f,
f_lower=low_frequency_cutoff,
approximant=approximant,
df=delta_f)
except (ValueError, KeyError) :
except (ValueError, KeyError) as e:
if isinstance(e, KeyError):
warnings.warn(
"self.get_decompressed_waveform has raised a KeyError. "
"This may be as the compressed waveform has not been "
"generated for this approximant, but it could indicate "
"a more serious issue. Approximant: %s" % approximant
)
htilde = pycbc.waveform.get_waveform_filter(
cached_mem, self.table[t_num], approximant=approximant,
f_lower=low_frequency_cutoff, f_final=max_freq, delta_f=delta_f,
Expand Down Expand Up @@ -821,7 +829,14 @@ def __getitem__(self, index):
htilde = self.get_decompressed_waveform(tempout, index, f_lower=f_low,
approximant=approximant, df=None)

except (ValueError, KeyError) :
except (ValueError, KeyError) as e:
if isinstance(e, KeyError):
warnings.warn(
"self.get_decompressed_waveform has raised a KeyError. "
"This may be as the compressed waveform has not been "
"generated for this approximant, but it could indicate "
"a more serious issue. Approximant: %s" % approximant
)
htilde = pycbc.waveform.get_waveform_filter(
tempout[0:self.filter_length], self.table[index],
approximant=approximant, f_lower=f_low, f_final=f_end,
Expand Down

0 comments on commit 1d3ac81

Please # to comment.