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

Function test_csp_component_ordering

mne/decoding/tests/test_csp.py:471–491  ·  view source on GitHub ↗

Test that CSP component ordering works as expected.

()

Source from the content-addressed store, hash-verified

469
470
471def test_csp_component_ordering():
472 """Test that CSP component ordering works as expected."""
473 x, y = deterministic_toy_data(["class_a", "class_b"])
474
475 csp = CSP(component_order="invalid")
476 with pytest.raises(ValueError, match="Invalid value"):
477 csp.fit(x, y)
478
479 # component_order='alternate' only works with two classes
480 csp = CSP(component_order="alternate")
481 with pytest.raises(ValueError):
482 csp.fit(np.zeros((3, 0, 0)), ["a", "b", "c"])
483
484 p_alt = CSP(component_order="alternate").fit(x, y).patterns_
485 p_mut = CSP(component_order="mutual_info").fit(x, y).patterns_
486
487 # This permutation of p_alt and p_mut is explained by the particular
488 # eigenvalues of the toy data: [0.06, 0.1, 0.5, 0.8].
489 # p_alt arranges them to [0.8, 0.06, 0.5, 0.1]
490 # p_mut arranges them to [0.06, 0.1, 0.8, 0.5]
491 assert_array_almost_equal(p_alt, p_mut[[2, 0, 3, 1]])
492
493
494@pytest.mark.filterwarnings("ignore:.*Only one sample available.*")

Callers

nothing calls this directly

Calls 4

fitMethod · 0.95
CSPClass · 0.90
deterministic_toy_dataFunction · 0.85
fitMethod · 0.45

Tested by

no test coverage detected