#NEWLINE# def test_shift_time_evoked( ) : #NEWLINE# #INDENT# ' Test for shifting of time scale\n    ' #NEWLINE# tempdir = _TempDir ( ) #NEWLINE# ave = read_evokeds ( fname , 0 ) #NEWLINE# ave . shift_time ( ( - 0.1 ) , relative = True ) #NEWLINE# write_evokeds ( op . join ( tempdir , 'evoked-ave.fif' ) , ave ) #NEWLINE# ave_bshift = read_evokeds ( op . join ( tempdir , 'evoked-ave.fif' ) , 0 ) #NEWLINE# ave_bshift . shift_time ( 0.2 , relative = True ) #NEWLINE# write_evokeds ( op . join ( tempdir , 'evoked-ave.fif' ) , ave_bshift ) #NEWLINE# ave_fshift = read_evokeds ( op . join ( tempdir , 'evoked-ave.fif' ) , 0 ) #NEWLINE# ave_fshift . shift_time ( ( - 0.1 ) , relative = True ) #NEWLINE# write_evokeds ( op . join ( tempdir , 'evoked-ave.fif' ) , ave_fshift ) #NEWLINE# ave_normal = read_evokeds ( fname , 0 ) #NEWLINE# ave_relative = read_evokeds ( op . join ( tempdir , 'evoked-ave.fif' ) , 0 ) #NEWLINE# assert_true ( np . allclose ( ave_normal . data , ave_relative . data , atol = 1e-16 , rtol = 0.001 ) ) #NEWLINE# assert_array_almost_equal ( ave_normal . times , ave_relative . times , 10 ) #NEWLINE# assert_equal ( ave_normal . last , ave_relative . last ) #NEWLINE# assert_equal ( ave_normal . first , ave_relative . first ) #NEWLINE# ave = read_evokeds ( fname , 0 ) #NEWLINE# ave . shift_time ( ( - 0.3 ) , relative = False ) #NEWLINE# write_evokeds ( op . join ( tempdir , 'evoked-ave.fif' ) , ave ) #NEWLINE# ave_absolute = read_evokeds ( op . join ( tempdir , 'evoked-ave.fif' ) , 0 ) #NEWLINE# assert_true ( np . allclose ( ave_normal . data , ave_absolute . data , atol = 1e-16 , rtol = 0.001 ) ) #NEWLINE# assert_equal ( ave_absolute . first , int ( ( ( - 0.3 ) * ave . info [ 'sfreq' ] ) ) )