<s> import numpy as np <EOL> from numpy . testing import ( assert_array_almost_equal , assert_almost_equal , <EOL> assert_array_equal , assert_allclose ) <EOL> from nose . tools import assert_equal , assert_true , assert_raises <EOL> import warnings <EOL> from scipy . signal import resample as sp_resample <EOL> from mne . filter import ( band_pass_filter , high_pass_filter , low_pass_filter , <EOL> band_stop_filter , resample , _resample_stim_channels , <EOL> construct_iir_filter , notch_filter , detrend , <EOL> _overlap_add_filter , _smart_pad ) <EOL> from mne . utils import sum_squared , run_tests_if_main , slow_test , catch_logging <EOL> warnings . simplefilter ( '<STR_LIT>' ) <EOL> rng = np . random . RandomState ( <NUM_LIT:0> ) <EOL> def test_1d_filter ( ) : <EOL> """<STR_LIT>""" <EOL> for n_signal in ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT:100> , <NUM_LIT:200> , <NUM_LIT> , <NUM_LIT:1000> , <NUM_LIT> ) : <EOL> x = rng . randn ( n_signal ) <EOL> for n_filter in ( <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT:100> , <NUM_LIT:200> , <NUM_LIT> , <NUM_LIT:1000> , <NUM_LIT> ) : <EOL> if n_filter > n_signal : <EOL> continue <EOL> for filter_type in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if filter_type == '<STR_LIT>' : <EOL> h = rng . randn ( n_filter ) <EOL> else : <EOL> h = np . concatenate ( [ [ <NUM_LIT:1.> ] , np . zeros ( n_filter - <NUM_LIT:1> ) ] ) <EOL> n_pad = max ( min ( n_filter , n_signal - <NUM_LIT:1> ) , <NUM_LIT:0> ) <EOL> x_pad = _smart_pad ( x , np . array ( [ n_pad , n_pad ] ) ) <EOL> for zero_phase in ( True , False ) : <EOL> if zero_phase : <EOL> x_expected = np . convolve ( x_pad , h ) [ : : - <NUM_LIT:1> ] <EOL> x_expected = np . convolve ( x_expected , h ) [ : : - <NUM_LIT:1> ] <EOL> x_expected = x_expected [ len ( h ) - <NUM_LIT:1> : - ( len ( h ) - <NUM_LIT:1> ) ] <EOL> else : <EOL> x_expected = np . convolve ( x_pad , h ) <EOL> x_expected = x_expected [ : - ( len ( h ) - <NUM_LIT:1> ) ] <EOL> if n_pad > <NUM_LIT:0> : <EOL> x_expected = x_expected [ n_pad : - n_pad ] <EOL> if filter_type == '<STR_LIT>' : <EOL> assert_allclose ( x_expected , x ) <EOL> for n_fft in ( None , <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) : <EOL> x_copy = x [ np . newaxis , : ] . copy ( ) <EOL> if ( n_fft is not None and n_fft < <NUM_LIT:2> * n_filter - <NUM_LIT:1> and <EOL> zero_phase ) : <EOL> assert_raises ( ValueError , _overlap_add_filter , <EOL> x_copy , h , n_fft , zero_phase ) <EOL> elif ( n_fft is not None and n_fft < n_filter and not <EOL> zero_phase ) : <EOL> assert_raises ( ValueError , _overlap_add_filter , <EOL> x_copy , h , n_fft , zero_phase ) <EOL> else : <EOL> with warnings . catch_warnings ( record = True ) : <EOL> x_filtered = _overlap_add_filter ( <EOL> x_copy , h , n_fft , zero_phase ) [ <NUM_LIT:0> ] <EOL> assert_allclose ( x_expected , x_filtered ) <EOL> def test_iir_stability ( ) : <EOL> """<STR_LIT>""" <EOL> sig = np . empty ( <NUM_LIT:1000> ) <EOL> sfreq = <NUM_LIT:1000> <EOL> assert_raises ( RuntimeError , high_pass_filter , sig , sfreq , <NUM_LIT> , <EOL> method = '<STR_LIT>' , iir_params = dict ( ftype = '<STR_LIT>' , order = <NUM_LIT:8> ) ) <EOL> assert_raises ( ValueError , high_pass_filter , sig , sfreq , <NUM_LIT:0.1> , <EOL> method = '<STR_LIT>' , iir_params = dict ( ftype = '<STR_LIT>' , order = <NUM_LIT:2> ) ) <EOL> assert_raises ( TypeError , high_pass_filter , sig , sfreq , <NUM_LIT:0.1> , <EOL> method = <NUM_LIT:1> ) <EOL> assert_raises ( ValueError , high_pass_filter , sig , sfreq , <NUM_LIT:0.1> , <EOL> method = '<STR_LIT>' ) <EOL> assert_raises ( ValueError , high_pass_filter , sig , sfreq , <NUM_LIT:0.1> , <EOL> method = '<STR_LIT>' , iir_params = '<STR_LIT>' ) <EOL> high_pass_filter ( sig , <NUM_LIT> , <NUM_LIT:0.5> , method = '<STR_LIT>' , <EOL> iir_params = dict ( ftype = '<STR_LIT>' , order = <NUM_LIT:6> ) ) <EOL> def test_notch_filters ( ) : <EOL> """<STR_LIT>""" <EOL> sfreq = <NUM_LIT> <EOL> sig_len_secs = <NUM_LIT:20> <EOL> t = np . arange ( <NUM_LIT:0> , int ( sig_len_secs * sfreq ) ) / sfreq <EOL> freqs = np . arange ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> a = rng . randn ( int ( sig_len_secs * sfreq ) ) <EOL> orig_power = np . sqrt ( np . mean ( a ** <NUM_LIT:2> ) ) <EOL> a += np . sum ( [ np . sin ( <NUM_LIT:2> * np . pi * f * t ) for f in freqs ] , axis = <NUM_LIT:0> ) <EOL> assert_raises ( ValueError , notch_filter , a , sfreq , None , '<STR_LIT>' ) <EOL> assert_raises ( ValueError , notch_filter , a , sfreq , None , '<STR_LIT>' ) <EOL> methods = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> filter_lengths = [ None , None , None , <NUM_LIT> , None ] <EOL> line_freqs = [ None , freqs , freqs , freqs , freqs ] <EOL> tols = [ <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] <EOL> for meth , lf , fl , tol in zip ( methods , line_freqs , filter_lengths , tols ) : <EOL> with catch_logging ( ) as log_file : <EOL> b = notch_filter ( a , sfreq , lf , filter_length = fl , method = meth , <EOL> verbose = '<STR_LIT>' ) <EOL> if lf is None : <EOL> out = log_file . getvalue ( ) . split ( '<STR_LIT:\n>' ) [ : - <NUM_LIT:1> ] <EOL> if len ( out ) != <NUM_LIT:2> and len ( out ) != <NUM_LIT:3> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> out = np . fromstring ( out [ - <NUM_LIT:1> ] , sep = '<STR_LIT:U+002CU+0020>' ) <EOL> assert_array_almost_equal ( out , freqs ) <EOL> new_power = np . sqrt ( sum_squared ( b ) / b . size ) <EOL> assert_almost_equal ( new_power , orig_power , tol ) <EOL> def test_resample ( ) : <EOL> """<STR_LIT>""" <EOL> x = rng . normal ( <NUM_LIT:0> , <NUM_LIT:1> , ( <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ) ) <EOL> x_rs = resample ( x , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:10> ) <EOL> assert_equal ( x . shape , ( <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ) ) <EOL> assert_equal ( x_rs . shape , ( <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:5> ) ) <EOL> x_2 = x . swapaxes ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> x_2_rs = resample ( x_2 , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:10> ) <EOL> assert_array_equal ( x_2_rs . swapaxes ( <NUM_LIT:0> , <NUM_LIT:1> ) , x_rs ) <EOL> x_3 = x . swapaxes ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> x_3_rs = resample ( x_3 , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:10> , <NUM_LIT:0> ) <EOL> assert_array_equal ( x_3_rs . swapaxes ( <NUM_LIT:0> , <NUM_LIT:2> ) , x_rs ) <EOL> assert_array_equal ( resample ( [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:2> , <NUM_LIT:1> ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> def test_resample_stim_channel ( ) : <EOL> """<STR_LIT>""" <EOL> assert_array_equal ( <EOL> _resample_stim_channels ( [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> [ [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> ] ] ) <EOL> assert_array_equal ( <EOL> _resample_stim_channels ( [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:1> , <NUM_LIT> ) , <EOL> [ [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> ] ] ) <EOL> assert_array_equal ( <EOL> _resample_stim_channels ( [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> [ [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ] ] ) <EOL> assert_array_equal ( <EOL> _resample_stim_channels ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <NUM_LIT:2> , <NUM_LIT:1> ) , [ [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> ] ] ) <EOL> assert_array_equal ( <EOL> _resample_stim_channels ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <NUM_LIT> , <NUM_LIT:1> ) , [ [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:3> ] ] ) <EOL> data_chunk = np . zeros ( ( <NUM_LIT:1> , <NUM_LIT> ) ) <EOL> for new_data_len in ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) : <EOL> new_data = _resample_stim_channels ( data_chunk , new_data_len , <EOL> data_chunk . shape [ <NUM_LIT:1> ] ) <EOL> assert_equal ( new_data . shape [ <NUM_LIT:1> ] , new_data_len ) <EOL> @ slow_test <EOL> def test_filters ( ) : <EOL> """<STR_LIT>""" <EOL> sfreq = <NUM_LIT> <EOL> sig_len_secs = <NUM_LIT:30> <EOL> a = rng . randn ( <NUM_LIT:2> , sig_len_secs * sfreq ) <EOL> for fl in [ '<STR_LIT>' , [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> assert_raises ( ValueError , band_pass_filter , a , sfreq , <NUM_LIT:4> , <NUM_LIT:8> , <EOL> filter_length = fl ) <EOL> for nj in [ '<STR_LIT>' , <NUM_LIT:0.5> ] : <EOL> assert_raises ( ValueError , band_pass_filter , a , sfreq , <NUM_LIT:4> , <NUM_LIT:8> , n_jobs = nj ) <EOL> assert_raises ( ValueError , band_pass_filter , a , sfreq , <NUM_LIT:4> , sfreq / <NUM_LIT> ) <EOL> assert_raises ( ValueError , low_pass_filter , a , sfreq , sfreq / <NUM_LIT> ) <EOL> with warnings . catch_warnings ( record = True ) as w : <EOL> band_pass_filter ( a , sfreq , <NUM_LIT:1> , <NUM_LIT:8> , filter_length = <NUM_LIT> ) <EOL> band_pass_filter ( a , sfreq , <NUM_LIT:1> , <NUM_LIT:8> , filter_length = '<STR_LIT>' ) <EOL> assert_true ( len ( w ) >= <NUM_LIT:2> ) <EOL> for fl in [ '<STR_LIT>' , '<STR_LIT>' , None ] : <EOL> bp = band_pass_filter ( a , sfreq , <NUM_LIT:4> , <NUM_LIT:8> , filter_length = fl ) <EOL> bs = band_stop_filter ( a , sfreq , <NUM_LIT:4> - <NUM_LIT:0.5> , <NUM_LIT:8> + <NUM_LIT:0.5> , filter_length = fl ) <EOL> lp = low_pass_filter ( a , sfreq , <NUM_LIT:8> , filter_length = fl , n_jobs = <NUM_LIT:2> ) <EOL> hp = high_pass_filter ( lp , sfreq , <NUM_LIT:4> , filter_length = fl ) <EOL> assert_array_almost_equal ( hp , bp , <NUM_LIT:2> ) <EOL> assert_array_almost_equal ( bp + bs , a , <NUM_LIT:1> ) <EOL> filter_length = <NUM_LIT> <EOL> bp_oa = band_pass_filter ( a , sfreq , <NUM_LIT:4> , <NUM_LIT:8> , filter_length ) <EOL> bs_oa = band_stop_filter ( a , sfreq , <NUM_LIT:4> - <NUM_LIT:0.5> , <NUM_LIT:8> + <NUM_LIT:0.5> , filter_length ) <EOL> lp_oa = low_pass_filter ( a , sfreq , <NUM_LIT:8> , filter_length ) <EOL> hp_oa = high_pass_filter ( lp_oa , sfreq , <NUM_LIT:4> , filter_length ) <EOL> assert_array_almost_equal ( hp_oa , bp_oa , <NUM_LIT:2> ) <EOL> assert_array_almost_equal ( bp_oa + bs_oa , a , <NUM_LIT:1> ) <EOL> n_edge_ignore = <NUM_LIT:0> <EOL> assert_array_almost_equal ( hp [ n_edge_ignore : - n_edge_ignore ] , <EOL> hp_oa [ n_edge_ignore : - n_edge_ignore ] , <NUM_LIT:2> ) <EOL> n_resamp_ignore = <NUM_LIT:10> <EOL> bp_up_dn = resample ( resample ( bp_oa , <NUM_LIT:2> , <NUM_LIT:1> , n_jobs = <NUM_LIT:2> ) , <NUM_LIT:1> , <NUM_LIT:2> , n_jobs = <NUM_LIT:2> ) <EOL> assert_array_almost_equal ( bp_oa [ n_resamp_ignore : - n_resamp_ignore ] , <EOL> bp_up_dn [ n_resamp_ignore : - n_resamp_ignore ] , <NUM_LIT:2> ) <EOL> bp_up_dn = resample ( resample ( bp_oa , <NUM_LIT:2> , <NUM_LIT:1> , n_jobs = '<STR_LIT>' ) , <NUM_LIT:1> , <NUM_LIT:2> , <EOL> n_jobs = '<STR_LIT>' ) <EOL> assert_array_almost_equal ( bp_oa [ n_resamp_ignore : - n_resamp_ignore ] , <EOL> bp_up_dn [ n_resamp_ignore : - n_resamp_ignore ] , <NUM_LIT:2> ) <EOL> bp_up_dn = sp_resample ( sp_resample ( bp_oa , <NUM_LIT:2> * bp_oa . shape [ - <NUM_LIT:1> ] , axis = - <NUM_LIT:1> , <EOL> window = '<STR_LIT>' ) , <EOL> bp_oa . shape [ - <NUM_LIT:1> ] , window = '<STR_LIT>' , axis = - <NUM_LIT:1> ) <EOL> assert_array_almost_equal ( bp_oa [ n_resamp_ignore : - n_resamp_ignore ] , <EOL> bp_up_dn [ n_resamp_ignore : - n_resamp_ignore ] , <NUM_LIT:2> ) <EOL> t = np . array ( list ( range ( sfreq * sig_len_secs ) ) ) / float ( sfreq ) <EOL> sig = np . sin ( <NUM_LIT:2> * np . pi * sfreq / <NUM_LIT> * t ) <EOL> sig_gone = resample ( sig , <NUM_LIT:1> , <NUM_LIT:2> ) [ n_resamp_ignore : - n_resamp_ignore ] <EOL> assert_array_almost_equal ( np . zeros_like ( sig_gone ) , sig_gone , <NUM_LIT:2> ) <EOL> iir_params = dict ( ftype = '<STR_LIT>' , gpass = <NUM_LIT:1> , gstop = <NUM_LIT:20> ) <EOL> iir_params = construct_iir_filter ( iir_params , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1000> , '<STR_LIT>' ) <EOL> assert_true ( iir_params [ '<STR_LIT:a>' ] . size - <NUM_LIT:1> == <NUM_LIT:3> ) <EOL> assert_true ( iir_params [ '<STR_LIT:b>' ] . size - <NUM_LIT:1> == <NUM_LIT:3> ) <EOL> iir_params = dict ( ftype = '<STR_LIT>' , order = <NUM_LIT:4> ) <EOL> iir_params = construct_iir_filter ( iir_params , <NUM_LIT> , None , <NUM_LIT:1000> , '<STR_LIT>' ) <EOL> assert_true ( iir_params [ '<STR_LIT:a>' ] . size - <NUM_LIT:1> == <NUM_LIT:4> ) <EOL> assert_true ( iir_params [ '<STR_LIT:b>' ] . size - <NUM_LIT:1> == <NUM_LIT:4> ) <EOL> a = rng . randn ( <NUM_LIT:5> * sfreq , <NUM_LIT:5> * sfreq ) <EOL> b = a [ : , None , : ] <EOL> with warnings . catch_warnings ( record = True ) as w : <EOL> a_filt = band_pass_filter ( a , sfreq , <NUM_LIT:4> , <NUM_LIT:8> ) <EOL> b_filt = band_pass_filter ( b , sfreq , <NUM_LIT:4> , <NUM_LIT:8> , picks = [ <NUM_LIT:0> ] ) <EOL> assert_array_equal ( a_filt [ : , None , : ] , b_filt ) <EOL> a = rng . randn ( <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> assert_raises ( ValueError , band_pass_filter , a , sfreq , Fp1 = <NUM_LIT:4> , Fp2 = <NUM_LIT:8> , <EOL> picks = np . array ( [ <NUM_LIT:0> , <NUM_LIT:1> ] ) ) <EOL> N = <NUM_LIT> <EOL> sfreq = <NUM_LIT> <EOL> lp = <NUM_LIT> <EOL> sine_freq = <NUM_LIT:1.> <EOL> x = np . ones ( N ) <EOL> x += np . sin ( <NUM_LIT:2> * np . pi * sine_freq * np . arange ( N ) / sfreq ) <EOL> with warnings . catch_warnings ( record = True ) : <EOL> x_filt = low_pass_filter ( x , sfreq , lp , '<STR_LIT>' ) <EOL> assert_allclose ( x , x_filt , rtol = <NUM_LIT> , atol = <NUM_LIT> ) <EOL> def test_cuda ( ) : <EOL> """<STR_LIT>""" <EOL> sfreq = <NUM_LIT> <EOL> sig_len_secs = <NUM_LIT:20> <EOL> a = rng . randn ( sig_len_secs * sfreq ) <EOL> with catch_logging ( ) as log_file : <EOL> for fl in [ '<STR_LIT>' , None , <NUM_LIT> ] : <EOL> bp = band_pass_filter ( a , sfreq , <NUM_LIT:4> , <NUM_LIT:8> , n_jobs = <NUM_LIT:1> , filter_length = fl ) <EOL> bs = band_stop_filter ( a , sfreq , <NUM_LIT:4> - <NUM_LIT:0.5> , <NUM_LIT:8> + <NUM_LIT:0.5> , n_jobs = <NUM_LIT:1> , <EOL> filter_length = fl ) <EOL> lp = low_pass_filter ( a , sfreq , <NUM_LIT:8> , n_jobs = <NUM_LIT:1> , filter_length = fl ) <EOL> hp = high_pass_filter ( lp , sfreq , <NUM_LIT:4> , n_jobs = <NUM_LIT:1> , filter_length = fl ) <EOL> bp_c = band_pass_filter ( a , sfreq , <NUM_LIT:4> , <NUM_LIT:8> , n_jobs = '<STR_LIT>' , <EOL> filter_length = fl , verbose = '<STR_LIT>' ) <EOL> bs_c = band_stop_filter ( a , sfreq , <NUM_LIT:4> - <NUM_LIT:0.5> , <NUM_LIT:8> + <NUM_LIT:0.5> , n_jobs = '<STR_LIT>' , <EOL> filter_length = fl , verbose = '<STR_LIT>' ) <EOL> lp_c = low_pass_filter ( a , sfreq , <NUM_LIT:8> , n_jobs = '<STR_LIT>' , <EOL> filter_length = fl , verbose = '<STR_LIT>' ) <EOL> hp_c = high_pass_filter ( lp , sfreq , <NUM_LIT:4> , n_jobs = '<STR_LIT>' , <EOL> filter_length = fl , verbose = '<STR_LIT>' ) <EOL> assert_array_almost_equal ( bp , bp_c , <NUM_LIT:12> ) <EOL> assert_array_almost_equal ( bs , bs_c , <NUM_LIT:12> ) <EOL> assert_array_almost_equal ( lp , lp_c , <NUM_LIT:12> ) <EOL> assert_array_almost_equal ( hp , hp_c , <NUM_LIT:12> ) <EOL> out = log_file . getvalue ( ) . split ( '<STR_LIT:\n>' ) [ : - <NUM_LIT:1> ] <EOL> from mne . cuda import _cuda_capable <EOL> tot = <NUM_LIT:12> if _cuda_capable else <NUM_LIT:0> <EOL> assert_true ( sum ( [ '<STR_LIT>' in o <EOL> for o in out ] ) == tot ) <EOL> for window in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> for N in ( <NUM_LIT> , <NUM_LIT:1000> ) : <EOL> a = rng . randn ( <NUM_LIT:2> , N ) <EOL> for fro , to in ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , ( <NUM_LIT:2> , <NUM_LIT:1> ) , ( <NUM_LIT:1> , <NUM_LIT:3> ) , ( <NUM_LIT:3> , <NUM_LIT:1> ) ) : <EOL> a1 = resample ( a , fro , to , n_jobs = <NUM_LIT:1> , npad = '<STR_LIT>' , <EOL> window = window ) <EOL> a2 = resample ( a , fro , to , n_jobs = '<STR_LIT>' , npad = '<STR_LIT>' , <EOL> window = window ) <EOL> assert_allclose ( a1 , a2 , rtol = <NUM_LIT> , atol = <NUM_LIT> ) <EOL> assert_array_almost_equal ( a1 , a2 , <NUM_LIT> ) <EOL> assert_array_equal ( resample ( [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT:2> , <NUM_LIT:1> , n_jobs = '<STR_LIT>' ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> assert_array_equal ( resample ( np . zeros ( <NUM_LIT:2> , np . float32 ) , <NUM_LIT:2> , <NUM_LIT:1> , n_jobs = '<STR_LIT>' ) , <EOL> [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> def test_detrend ( ) : <EOL> """<STR_LIT>""" <EOL> x = np . arange ( <NUM_LIT:10> ) <EOL> assert_array_almost_equal ( detrend ( x , <NUM_LIT:1> ) , np . zeros_like ( x ) ) <EOL> x = np . ones ( <NUM_LIT:10> ) <EOL> assert_array_almost_equal ( detrend ( x , <NUM_LIT:0> ) , np . zeros_like ( x ) ) <EOL> run_tests_if_main ( ) </s>
