8000 Fix faulty state check · tsbinns/mne-python@b14a100 · GitHub
[go: up one dir, main page]

Skip to content

Commit b14a100

Browse files
committed
Fix faulty state check
1 parent ca27179 commit b14a100

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

mne/time_frequency/tfr.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,26 +1501,25 @@ def _check_state(self):
15011501
msg = "{} axis of data ({}) doesn't match {} attribute ({})"
15021502
n_chan_info = len(self.info["chs"])
15031503
n_chan = self._data.shape[self._dims.index("channel")]
1504+
n_freq = self._data.shape[self._dims.index("freq")]
1505+
n_time = self._data.shape[self._dims.index("time")]
15041506
n_taper = (
15051507
self._data.shape[self._dims.index("taper")]
15061508
if "taper" in self._dims
15071509
else None
15081510
)
1509-
n_freq = self._data.shape[self._dims.index("freq")]
1510-
n_time = self._data.shape[self._dims.index("time")]
1511+
if n_taper is not None and self._weights is None:
1512+
raise ValueError("Taper dimension in data, but no weights found.")
15111513
if n_chan_info != n_chan:
15121514
msg = msg.format("Channel", n_chan, "info", n_chan_info)
1513-
elif n_taper is not None:
1514-
if self._weights is None:
1515-
raise RuntimeError("Taper dimension in data, but no weights found.")
1516-
if n_taper != self._weights.shape[0]:
1517-
msg = msg.format("Taper", n_taper, "weights", self._weights.shape[0])
1518-
elif n_freq != self._weights.shape[1]:
1519-
msg = msg.format("Frequency", n_freq, "weights", self._weights.shape[1])
15201515
elif n_freq != len(self.freqs):
15211516
msg = msg.format("Frequency", n_freq, "freqs", self.freqs.size)
15221517
elif n_time != len(self.times):
15231518
msg = msg.format("Time", n_time, "times", self.times.size)
1519+
elif n_taper is not None and n_taper != self._weights.shape[0]:
1520+
msg = msg.format("Taper", n_taper, "weights", self._weights.shape[0])
1521+
elif n_taper is not None and n_freq != self._weights.shape[1]:
1522+
msg = msg.format("Frequency", n_freq, "weights", self._weights.shape[1])
15241523
else:
15251524
return
15261525
raise ValueError(msg)

0 commit comments

Comments
 (0)
0