Ensure data are preloaded.
(inst, msg)
| 329 | |
| 330 | |
| 331 | def _check_preload(inst, msg): |
| 332 | """Ensure data are preloaded.""" |
| 333 | from ..epochs import BaseEpochs |
| 334 | from ..evoked import Evoked |
| 335 | from ..source_estimate import _BaseSourceEstimate |
| 336 | from ..time_frequency import BaseTFR |
| 337 | from ..time_frequency.spectrum import BaseSpectrum |
| 338 | |
| 339 | if isinstance(inst, BaseTFR | Evoked | BaseSpectrum | _BaseSourceEstimate): |
| 340 | pass |
| 341 | else: |
| 342 | name = "epochs" if isinstance(inst, BaseEpochs) else "raw" |
| 343 | if not inst.preload: |
| 344 | raise RuntimeError( |
| 345 | "By default, MNE does not load data into main memory to " |
| 346 | "conserve resources. " + msg + f" requires {name} data to be " |
| 347 | "loaded. Use preload=True (or string) in the constructor or " |
| 348 | f"{name}.load_data()." |
| 349 | ) |
| 350 | if name == "epochs": |
| 351 | inst._handle_empty("raise", msg) |
| 352 | |
| 353 | |
| 354 | def _check_compensation_grade(info1, info2, name1, name2="data", ch_names=None): |
no test coverage detected