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

Function test_si_units

mne/tests/test_defaults.py:31–47  ·  view source on GitHub ↗

Test that our scalings actually produce SI units.

()

Source from the content-addressed store, hash-verified

29
30
31def test_si_units():
32 """Test that our scalings actually produce SI units."""
33 scalings = _handle_default("scalings", None)
34 units = _handle_default("units", None)
35 # Add a bad one to test that we actually detect it
36 assert "csd_bad" not in scalings
37 scalings["csd_bad"] = 1e5
38 units["csd_bad"] = "V/m²"
39 assert set(scalings) == set(units)
40
41 for key, scale in scalings.items():
42 if key == "csd_bad":
43 with pytest.raises(KeyError, match="is not a channel type"):
44 want_scale = _get_scaling(key, units[key])
45 else:
46 want_scale = _get_scaling(key, units[key])
47 assert_allclose(scale, want_scale, rtol=1e-12)
48
49
50@pytest.mark.parametrize("key", ("si_units", "color", "scalings", "scalings_plot_raw"))

Callers

nothing calls this directly

Calls 3

_handle_defaultFunction · 0.90
_get_scalingFunction · 0.90
setFunction · 0.85

Tested by

no test coverage detected