<s> import numpy as np <EOL> from nose . tools import assert_raises <EOL> from numpy . testing import assert_array_almost_equal <EOL> from distutils . version import LooseVersion <EOL> from mne . time_frequency import psd_multitaper <EOL> from mne . time_frequency . multitaper import dpss_windows <EOL> from mne . utils import requires_nitime <EOL> from mne . io import RawArray <EOL> from mne import create_info <EOL> @ requires_nitime <EOL> def test_dpss_windows ( ) : <EOL> """<STR_LIT>""" <EOL> import nitime as ni <EOL> N = <NUM_LIT:1000> <EOL> half_nbw = <NUM_LIT:4> <EOL> Kmax = int ( <NUM_LIT:2> * half_nbw ) <EOL> dpss , eigs = dpss_windows ( N , half_nbw , Kmax , low_bias = False ) <EOL> dpss_ni , eigs_ni = ni . algorithms . dpss_windows ( N , half_nbw , Kmax ) <EOL> assert_array_almost_equal ( dpss , dpss_ni ) <EOL> assert_array_almost_equal ( eigs , eigs_ni ) <EOL> dpss , eigs = dpss_windows ( N , half_nbw , Kmax , interp_from = <NUM_LIT:200> , <EOL> low_bias = False ) <EOL> dpss_ni , eigs_ni = ni . algorithms . dpss_windows ( N , half_nbw , Kmax , <EOL> interp_from = <NUM_LIT:200> ) <EOL> assert_array_almost_equal ( dpss , dpss_ni ) <EOL> assert_array_almost_equal ( eigs , eigs_ni ) <EOL> @ requires_nitime <EOL> def test_multitaper_psd ( ) : <EOL> """<STR_LIT>""" <EOL> import nitime as ni <EOL> n_times = <NUM_LIT:1000> <EOL> n_channels = <NUM_LIT:5> <EOL> data = np . random . RandomState ( <NUM_LIT:0> ) . randn ( n_channels , n_times ) <EOL> sfreq = <NUM_LIT> <EOL> info = create_info ( n_channels , sfreq , '<STR_LIT>' ) <EOL> raw = RawArray ( data , info ) <EOL> assert_raises ( ValueError , psd_multitaper , raw , sfreq , normalization = '<STR_LIT:foo>' ) <EOL> ni_5 = ( LooseVersion ( ni . __version__ ) >= LooseVersion ( '<STR_LIT>' ) ) <EOL> norm = '<STR_LIT>' if ni_5 else '<STR_LIT>' <EOL> for adaptive , n_jobs in zip ( ( False , True , True ) , ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> ) ) : <EOL> psd , freqs = psd_multitaper ( raw , adaptive = adaptive , <EOL> n_jobs = n_jobs , <EOL> normalization = norm ) <EOL> freqs_ni , psd_ni , _ = ni . algorithms . spectral . multi_taper_psd ( <EOL> data , sfreq , adaptive = adaptive , jackknife = False ) <EOL> assert_array_almost_equal ( psd [ : , <NUM_LIT:1> : ] , psd_ni [ : , <NUM_LIT:1> : - <NUM_LIT:1> ] , decimal = <NUM_LIT:3> ) <EOL> assert_array_almost_equal ( freqs , freqs_ni [ : - <NUM_LIT:1> ] ) </s>
