#NEWLINE# def test_sg_coeffs_exact( ) : #NEWLINE# #INDENT# polyorder = 4 #NEWLINE# window_length = 9 #NEWLINE# halflen = ( window_length // 2 ) #NEWLINE# x = np . linspace ( 0 , 21 , 43 ) #NEWLINE# delta = ( x [ 1 ] - x [ 0 ] ) #NEWLINE# y = ( ( 0.5 * ( x ** 3 ) ) - x ) #NEWLINE# h = savgol_coeffs ( window_length , polyorder ) #NEWLINE# y0 = convolve1d ( y , h ) #NEWLINE# assert_allclose ( y0 [ halflen : ( - halflen ) ] , y [ halflen : ( - halflen ) ] ) #NEWLINE# dy = ( ( 1.5 * ( x ** 2 ) ) - 1 ) #NEWLINE# h = savgol_coeffs ( window_length , polyorder , deriv = 1 , delta = delta ) #NEWLINE# y1 = convolve1d ( y , h ) #NEWLINE# assert_allclose ( y1 [ halflen : ( - halflen ) ] , dy [ halflen : ( - halflen ) ] ) #NEWLINE# d2y = ( 3.0 * x ) #NEWLINE# h = savgol_coeffs ( window_length , polyorder , deriv = 2 , delta = delta ) #NEWLINE# y2 = convolve1d ( y , h ) #NEWLINE# assert_allclose ( y2 [ halflen : ( - halflen ) ] , d2y [ halflen : ( - halflen ) ] )