Skip to content

Commit b12edb9

Browse files
committed
Raise an IndexError when slicing a single-segment PS
1 parent cd800a8 commit b12edb9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

filter_functions/pulse_sequence.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ def __getitem__(self, key) -> 'PulseSequence':
384384
new_dt = np.atleast_1d(self.dt[key])
385385
if not new_dt.size:
386386
raise IndexError('Cannot create empty PulseSequence')
387+
if len(self) == 1:
388+
raise IndexError('invalid index to scalar (single-segment) PulseSequence')
387389

388390
new = self.__class__(
389391
c_opers=self.c_opers,

0 commit comments

Comments
 (0)