#NEWLINE# def test_antiderivative_vs_derivative( self ) : #NEWLINE# #INDENT# np . random . seed ( 1234 ) #NEWLINE# x = ( np . linspace ( 0 , 1 , 30 ) ** 2 ) #NEWLINE# y = np . random . rand ( len ( x ) ) #NEWLINE# spl = splrep ( x , y , s = 0 , k = 5 ) #NEWLINE# pp = PPoly . from_spline ( spl ) #NEWLINE# for dx in range ( 0 , 10 ) : #NEWLINE# #INDENT# ipp = pp . antiderivative ( dx ) #NEWLINE# pp2 = ipp . derivative ( dx ) #NEWLINE# assert_allclose ( pp . c , pp2 . c ) #NEWLINE# for k in range ( dx ) : #NEWLINE# #INDENT# pp2 = ipp . derivative ( k ) #NEWLINE# r = 1e-13 #NEWLINE# endpoint = ( ( r * pp2 . x [ : ( - 1 ) ] ) + ( ( 1 - r ) * pp2 . x [ 1 : ] ) ) #NEWLINE# assert_allclose ( pp2 ( pp2 . x [ 1 : ] ) , pp2 ( endpoint ) , rtol = 1e-07 , err_msg = ( 'dx=%d k=%d' % ( dx , k ) ) )