Skip to content

Commit

Permalink
Code Climate / reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
titodalcanton committed Aug 6, 2024
1 parent a80603c commit 227b8ab
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions pycbc/frame/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ def __init__(self, frame_src,
self.detector = channel_name.split(':')[0]

self.update_cache()
self.channel_type, self.raw_sample_rate = self._retrieve_metadata(self.stream, self.channel_name)
self.channel_type, self.raw_sample_rate = self._retrieve_metadata(
self.stream, self.channel_name
)

raw_size = self.raw_sample_rate * max_buffer
self.raw_buffer = TimeSeries(zeros(raw_size, dtype=dtype),
Expand Down Expand Up @@ -584,12 +586,20 @@ def _read_frame(self, blocksize):
try:
read_func = _fr_type_map[self.channel_type][0]
dtype = _fr_type_map[self.channel_type][1]
data = read_func(self.stream, self.channel_name,
self.read_pos, int(blocksize), 0)
return TimeSeries(data.data.data, delta_t=data.deltaT,
epoch=self.read_pos,
dtype=dtype)
except:
data = read_func(
self.stream,
self.channel_name,
self.read_pos,
int(blocksize),
0
)
return TimeSeries(
data.data.data,
delta_t=data.deltaT,
epoch=self.read_pos,
dtype=dtype
)
except Exception:
raise RuntimeError(f'Cannot read {self.channel_name} frame data')

def null_advance(self, blocksize):
Expand Down Expand Up @@ -664,8 +674,9 @@ def update_cache_by_increment(self, blocksize):
cache = locations_to_cache(keys)
stream = lalframe.FrStreamCacheOpen(cache)
self.stream = stream
self.channel_type, self.raw_sample_rate = \
self._retrieve_metadata(self.stream, self.channel_name)
self.channel_type, self.raw_sample_rate = self._retrieve_metadata(
self.stream, self.channel_name
)

def attempt_advance(self, blocksize, timeout=10):
""" Attempt to advance the frame buffer. Retry upon failure, except
Expand Down

0 comments on commit 227b8ab

Please sign in to comment.