Skip to content

Commit 336e9f6

Browse files
committed
More careful checking of pulse selection type
1 parent 8c1b922 commit 336e9f6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

extra_data/components.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,11 @@ def _sel_frames(self):
920920
s = np.ones(len(self.det.train_ids_perframe), np.bool_)
921921
else:
922922
s = self.det._select_pulse_indices(p, self.det.frame_counts)
923-
else: # by_id
923+
elif isinstance(p, by_id):
924924
pulse_ids = self.det._collect_inner_ids('pulseId')
925925
s = _select_pulse_ids(p, pulse_ids)
926+
else:
927+
raise TypeError(f"Pulse selection should not be {type(p)}")
926928
self._sel_frames_cached = s
927929
return self._sel_frames_cached
928930

@@ -1234,8 +1236,10 @@ def _get_pulse_data(self, source, key, tid):
12341236

12351237
if isinstance(self.pulses, by_id):
12361238
positions = self._select_pulse_ids(pulse_ids)
1237-
else: # by_index
1239+
elif isinstance(self.pulses, by_index):
12381240
positions = self._select_pulse_indices(count)
1241+
else:
1242+
raise TypeError(f"Pulse selection should not be {type(self.pulses)}")
12391243
pulse_ids = pulse_ids[positions]
12401244
train_ids = np.array([tid] * len(pulse_ids), dtype=np.uint64)
12411245
train_pulse_ids = self.data._make_image_index(train_ids, pulse_ids)

0 commit comments

Comments
 (0)