Skip to content

Commit bbc3900

Browse files
committed
fix test
1 parent 6cb1956 commit bbc3900

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

mne/viz/tests/test_raw.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -989,15 +989,11 @@ def test_plot_raw_filtered(filtorder, raw, browser_backend):
989989

990990
def _check_ylabel_psd(ylabel, amplitude, dB, unit):
991991
"""Check that the ylabel is correct."""
992-
if amplitude:
993-
assert "sqrt" in ylabel
994-
else:
995-
assert "Hz" in ylabel and "sqrt" not in ylabel
996-
if dB:
997-
assert "dB" in ylabel
998-
else:
999-
assert unit in ylabel, ylabel
1000-
assert "dB" not in ylabel
992+
numerator = "dB" if dB else unit
993+
denominator = r"\sqrt{\mathrm{Hz}}" if amplitude else r"\mathrm{Hz}"
994+
reference_val = rf"\ \mathrm{{re}}\ 1\ \mathrm{{{unit}}}" if dB else ""
995+
pattern = rf"\mathrm{{{numerator}}}/{denominator}{reference_val}"
996+
assert pattern in ylabel, ylabel
1001997

1002998

1003999
def test_plot_raw_psd(raw, raw_orig):
@@ -1051,18 +1047,18 @@ def test_plot_raw_psd(raw, raw_orig):
10511047
with pytest.warns(UserWarning, match="[Infinite|Zero]"):
10521048
spectrum = raw.compute_psd()
10531049
for dB, amplitude in itertools.product((True, False), (True, False)):
1054-
with pytest.warns(UserWarning, match="[Infinite|Zero]"):
1050+
with pytest.warns(UserWarning, match="(Infinite|Zero)"):
10551051
fig = spectrum.plot(average=True, dB=dB, amplitude=amplitude)
10561052
# check grad axes
10571053
title = fig.axes[0].get_title()
10581054
ylabel = fig.axes[0].get_ylabel()
1059-
unit = r"fT/cm/\sqrt{Hz}" if amplitude else "(fT/cm)²/Hz"
1055+
unit = "fT/cm" if amplitude else "(fT/cm)^2"
10601056
assert title == "Gradiometers", title
10611057
_check_ylabel_psd(ylabel, amplitude, dB, unit)
10621058
# check mag axes
10631059
title = fig.axes[1].get_title()
10641060
ylabel = fig.axes[1].get_ylabel()
1065-
unit = r"fT/\sqrt{Hz}" if amplitude else "fT²/Hz"
1061+
unit = "fT" if amplitude else "fT^2"
10661062
assert title == "Magnetometers", title
10671063
_check_ylabel_psd(ylabel, amplitude, dB, unit)
10681064

0 commit comments

Comments
 (0)