Skip to content

Commit 9b6138c

Browse files
committed
Update tests for plot updates
1 parent 2f00dd9 commit 9b6138c

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

fooof/tests/test_plts_spectra.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@
99
@plot_test
1010
def test_plot_spectrum(tfm, skip_if_no_mpl):
1111

12-
plot_spectrum(tfm.freqs, tfm.power_spectrum, True)
12+
plot_spectrum(tfm.freqs, tfm.power_spectrum)
13+
14+
# Test with logging both axes
15+
plot_spectrum(tfm.freqs, tfm.power_spectrum, True, True)
1316

1417
@plot_test
1518
def test_plot_spectra(tfg, skip_if_no_mpl):
1619

20+
# Test with 1d inputs - 1d freq array and list of 1d power spectra
1721
plot_spectra(tfg.freqs, [tfg.power_spectra[0, :], tfg.power_spectra[1, :]])
1822

23+
# Test with multiple freq inputs - list of 1d freq array and list of 1d power spectra
24+
plot_spectra([tfg.freqs, tfg.freqs], [tfg.power_spectra[0, :], tfg.power_spectra[1, :]])
25+
26+
# Test with 2d array inputs
27+
plot_spectra(np.vstack([tfg.freqs, tfg.freqs]),
28+
np.vstack([tfg.power_spectra[0, :], tfg.power_spectra[1, :]]))
29+
30+
# Test with labels
31+
plot_spectra(tfg.freqs, [tfg.power_spectra[0, :], tfg.power_spectra[1, :]], labels=['A', 'B'])
32+
1933
@plot_test
2034
def test_plot_spectrum_shading(tfm, skip_if_no_mpl):
2135

@@ -26,3 +40,8 @@ def test_plot_spectra_shading(tfg, skip_if_no_mpl):
2640

2741
plot_spectra_shading(tfg.freqs, [tfg.power_spectra[0, :], tfg.power_spectra[1, :]],
2842
shades=[8, 12], add_center=True)
43+
44+
# Test with **kwargs that pass into plot_spectra
45+
plot_spectra_shading(tfg.freqs, [tfg.power_spectra[0, :], tfg.power_spectra[1, :]],
46+
shades=[8, 12], add_center=True, log_freqs=True, log_powers=True,
47+
labels=['A', 'B'])

fooof/tests/test_plts_styles.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Tests for fooof.plts.styles."""
2+
3+
from fooof.plts.style import *
4+
5+
###################################################################################################
6+
###################################################################################################
7+
8+
def test_check_n_style(skip_if_no_mpl):
9+
10+
# Check can pass None and do nothing
11+
check_n_style(None)
12+
assert True
13+
14+
# Check can pass a callable
15+
def checker(*args):
16+
return True
17+
check_n_style(checker)
18+
19+
def test_style_spectrum_plot(skip_if_no_mpl):
20+
21+
# Create a dummy plot and style it
22+
from fooof.core.modutils import safe_import
23+
plt = safe_import('.pyplot', 'matplotlib')
24+
_, ax = plt.subplots()
25+
style_spectrum_plot(ax, False, False)
26+
27+
# Check that axis labels are added - use as proxy that it ran correctly
28+
assert ax.xaxis.get_label().get_text()
29+
assert ax.yaxis.get_label().get_text()

0 commit comments

Comments
 (0)