MCPcopy
hub / github.com/mne-tools/mne-python / test_plot_csd

Function test_plot_csd

mne/viz/tests/test_misc.py:332–366  ·  view source on GitHub ↗

Test plotting of CSD matrices.

(ch_types)

Source from the content-addressed store, hash-verified

330 ],
331)
332def test_plot_csd(ch_types):
333 """Test plotting of CSD matrices."""
334 if isinstance(ch_types, list):
335 n_ch_types = len(ch_types)
336 n_ch = 2 * n_ch_types
337 ch_types = np.repeat(ch_types, 2).tolist()
338 else:
339 n_ch = 2
340 ch_names = [f"CH{i + 1}" for i in range(n_ch)]
341 n_data = n_ch * (n_ch + 1) // 2
342
343 csd = CrossSpectralDensity(
344 np.arange(1, n_data + 1),
345 ch_names,
346 frequencies=[(10, 20)],
347 n_fft=1,
348 tmin=0,
349 tmax=1,
350 )
351
352 if ch_types is None:
353 info = None
354 expected_n_figs = 1
355 else:
356 info = create_info(ch_names, sfreq=1.0, ch_types=ch_types)
357 unique_types = set(ch_types) if isinstance(ch_types, list) else {ch_types}
358 expected_n_figs = len(unique_types)
359
360 for mode in ("csd", "coh"):
361 if ch_types == "misc":
362 with pytest.raises(RuntimeError, match="No plottable channel types"):
363 plot_csd(csd, info=info, mode=mode, show=False)
364 else:
365 figs = plot_csd(csd, info=info, mode=mode, show=False)
366 assert len(figs) == expected_n_figs
367
368
369@pytest.mark.slowtest # Slow on Azure

Callers

nothing calls this directly

Calls 4

create_infoFunction · 0.90
plot_csdFunction · 0.90
setFunction · 0.85

Tested by

no test coverage detected