Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idq live #4850

Merged
merged 15 commits into from
Aug 22, 2024
Prev Previous commit
Next Next commit
logger not logging
  • Loading branch information
maxtrevor committed Aug 22, 2024
commit f4fdac80303c601bfc1c7dd989a2d423a93e1cec
18 changes: 9 additions & 9 deletions pycbc/events/stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2411,22 +2411,22 @@ def find_dq_noise_rate(self, trigs):

try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This try/except is used a couple of times now. It would be good to be in a function. Codeclimate will probably complain

ifo = trigs.ifo
logging.info('DEBUG in find_dq_noise_rate: trigs.ifo worked successfully')
logger.info('DEBUG in find_dq_noise_rate: trigs.ifo worked successfully')
except AttributeError:
ifo = trigs.get('ifo', None)
if ifo is None:
logging.info('DEBUG in find_dq_noise_rate: ifo is none after trigs.get')
logging.info(f'DEBUG in find_dq_noise_rate: stat ifos: {self.ifos}')
logger.info('DEBUG in find_dq_noise_rate: ifo is none after trigs.get')
logger.info(f'DEBUG in find_dq_noise_rate: stat ifos: {self.ifos}')
ifo = self.ifos[0]
else:
logging.info('DEBUG in find_dq_noise_rate: trigs.get worked')
logger.info('DEBUG in find_dq_noise_rate: trigs.get worked')
assert ifo in self.ifos

dq_state = trigs['dq_state']
dq_val = numpy.ones(len(dq_state))

tnum = self.curr_tnum
GarethCabournDavies marked this conversation as resolved.
Show resolved Hide resolved
logging.info(f'DEBUG in find_dq_noise_rate: tnum: {tnum}')
logger.info(f'DEBUG in find_dq_noise_rate: tnum: {tnum}')
if ifo in self.dq_rates_by_state:
for (i, st) in enumerate(dq_state):
if isinstance(tnum, numpy.ndarray):
Expand Down Expand Up @@ -2479,15 +2479,15 @@ def single(self, trigs):
# make sure every trig has a dq state
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an if hasattr(self, 'ifo') would be nicer here than the try/except. However I know that is against EAFP, and this is how it is done elsewhere

ifo = trigs.ifo
logging.info('DEBUG in single: trigs.ifo worked successfully')
logger.info('DEBUG in single: trigs.ifo worked successfully')
except AttributeError:
ifo = trigs.get('ifo', None)
if ifo is None:
logging.info('DEBUG in single: ifo is none after trigs.get')
logging.info(f'DEBUG in single: stat ifos: {self.ifos}')
logger.info('DEBUG in single: ifo is none after trigs.get')
logger.info(f'DEBUG in single: stat ifos: {self.ifos}')
ifo = self.ifos[0]
else:
logging.info('DEBUG in single: trigs.get worked')
logger.info('DEBUG in single: trigs.get worked')
assert ifo in self.ifos

singles = ExpFitFgBgNormStatistic.single(self, trigs)
Expand Down