Skip to content

Commit

Permalink
Fix faulty state check
Browse files Browse the repository at this point in the history
  • Loading branch information
tsbinns committed Dec 10, 2024
1 parent ca27179 commit b14a100
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions mne/time_frequency/tfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,26 +1501,25 @@ def _check_state(self):
msg = "{} axis of data ({}) doesn't match {} attribute ({})"
n_chan_info = len(self.info["chs"])
n_chan = self._data.shape[self._dims.index("channel")]
n_freq = self._data.shape[self._dims.index("freq")]
n_time = self._data.shape[self._dims.index("time")]
n_taper = (
self._data.shape[self._dims.index("taper")]
if "taper" in self._dims
else None
)
n_freq = self._data.shape[self._dims.index("freq")]
n_time = self._data.shape[self._dims.index("time")]
if n_taper is not None and self._weights is None:
raise ValueError("Taper dimension in data, but no weights found.")
if n_chan_info != n_chan:
msg = msg.format("Channel", n_chan, "info", n_chan_info)
elif n_taper is not None:
if self._weights is None:
raise RuntimeError("Taper dimension in data, but no weights found.")
if n_taper != self._weights.shape[0]:
msg = msg.format("Taper", n_taper, "weights", self._weights.shape[0])
elif n_freq != self._weights.shape[1]:
msg = msg.format("Frequency", n_freq, "weights", self._weights.shape[1])
elif n_freq != len(self.freqs):
msg = msg.format("Frequency", n_freq, "freqs", self.freqs.size)
elif n_time != len(self.times):
msg = msg.format("Time", n_time, "times", self.times.size)
elif n_taper is not None and n_taper != self._weights.shape[0]:
msg = msg.format("Taper", n_taper, "weights", self._weights.shape[0])
elif n_taper is not None and n_freq != self._weights.shape[1]:
msg = msg.format("Frequency", n_freq, "weights", self._weights.shape[1])
else:
return
raise ValueError(msg)
Expand Down

0 comments on commit b14a100

Please sign in to comment.