Test that our scalings actually produce SI units.
()
| 29 | |
| 30 | |
| 31 | def 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")) |
nothing calls this directly
no test coverage detected