33import numpy as np
44
55from fooof .tests .tutils import plot_test
6+ from fooof .tests .settings import TEST_PLOTS_PATH
67
78from fooof .plts .spectra import *
89
@@ -15,36 +16,46 @@ def test_plot_spectrum(tfm, skip_if_no_mpl):
1516 plot_spectrum (tfm .freqs , tfm .power_spectrum )
1617
1718 # Test with logging both axes
18- plot_spectrum (tfm .freqs , tfm .power_spectrum , True , True )
19+ plot_spectrum (tfm .freqs , tfm .power_spectrum , True , True , save_fig = True ,
20+ file_path = TEST_PLOTS_PATH , file_name = 'test_plot_spectrum.png' )
1921
2022@plot_test
2123def test_plot_spectra (tfg , skip_if_no_mpl ):
2224
2325 # Test with 1d inputs - 1d freq array and list of 1d power spectra
24- plot_spectra (tfg .freqs , [tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]])
26+ plot_spectra (tfg .freqs , [tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]],
27+ save_fig = True , file_path = TEST_PLOTS_PATH , file_name = 'test_plot_spectra_1d.png' )
2528
2629 # Test with multiple freq inputs - list of 1d freq array and list of 1d power spectra
27- plot_spectra ([tfg .freqs , tfg .freqs ], [tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]])
30+ plot_spectra ([tfg .freqs , tfg .freqs ], [tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]],
31+ save_fig = True , file_path = TEST_PLOTS_PATH ,
32+ file_name = 'test_plot_spectra_list_of_1d.png' )
2833
2934 # Test with 2d array inputs
3035 plot_spectra (np .vstack ([tfg .freqs , tfg .freqs ]),
31- np .vstack ([tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]]))
36+ np .vstack ([tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]]),
37+ save_fig = True , file_path = TEST_PLOTS_PATH , file_name = 'test_plot_spectra_2d.png' )
3238
3339 # Test with labels
34- plot_spectra (tfg .freqs , [tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]], labels = ['A' , 'B' ])
40+ plot_spectra (tfg .freqs , [tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]], labels = ['A' , 'B' ],
41+ save_fig = True , file_path = TEST_PLOTS_PATH , file_name = 'test_plot_spectra_labels.png' )
3542
3643@plot_test
3744def test_plot_spectrum_shading (tfm , skip_if_no_mpl ):
3845
39- plot_spectrum_shading (tfm .freqs , tfm .power_spectrum , shades = [8 , 12 ], add_center = True )
46+ plot_spectrum_shading (tfm .freqs , tfm .power_spectrum , shades = [8 , 12 ], add_center = True ,
47+ save_fig = True , file_path = TEST_PLOTS_PATH ,
48+ file_name = 'test_plot_spectrum_shading.png' )
4049
4150@plot_test
4251def test_plot_spectra_shading (tfg , skip_if_no_mpl ):
4352
4453 plot_spectra_shading (tfg .freqs , [tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]],
45- shades = [8 , 12 ], add_center = True )
54+ shades = [8 , 12 ], add_center = True , save_fig = True , file_path = TEST_PLOTS_PATH ,
55+ file_name = 'test_plot_spectra_shading.png' )
4656
4757 # Test with **kwargs that pass into plot_spectra
4858 plot_spectra_shading (tfg .freqs , [tfg .power_spectra [0 , :], tfg .power_spectra [1 , :]],
4959 shades = [8 , 12 ], add_center = True , log_freqs = True , log_powers = True ,
50- labels = ['A' , 'B' ])
60+ labels = ['A' , 'B' ], save_fig = True , file_path = TEST_PLOTS_PATH ,
61+ file_name = 'test_plot_spectra_shading_kwargs.png' )
0 commit comments