#NEWLINE# def test_integrate( self ) : #NEWLINE# #INDENT# np . random . seed ( 1234 ) #NEWLINE# x = np . sort ( np . r_ [ ( 0 , np . random . rand ( 11 ) , 1 ) ] ) #NEWLINE# y = np . random . rand ( len ( x ) ) #NEWLINE# spl = splrep ( x , y , s = 0 , k = 5 ) #NEWLINE# pp = PPoly . from_spline ( spl ) #NEWLINE# ( a , b ) = ( 0.3 , 0.9 ) #NEWLINE# ig = pp . integrate ( a , b ) #NEWLINE# ipp = pp . antiderivative ( ) #NEWLINE# assert_allclose ( ig , ( ipp ( b ) - ipp ( a ) ) ) #NEWLINE# assert_allclose ( ig , splint ( a , b , spl ) ) #NEWLINE# ( a , b ) = ( ( - 0.3 ) , 0.9 ) #NEWLINE# ig = pp . integrate ( a , b , extrapolate = True ) #NEWLINE# assert_allclose ( ig , ( ipp ( ipp ) - ipp ( a ) ) ) #NEWLINE# assert_ ( np . isnan ( pp . integrate ( a , b , extrapolate = False ) ) . all ( ) )