#NEWLINE# def check_poly( self , func , param_ranges = [ ] , x_range = [ ] , nn = 10 , nparam = 10 , nx = 10 , rtol = 1e-08 ) : #NEWLINE# #INDENT# np . random . seed ( 1234 ) #NEWLINE# dataset = [ ] #NEWLINE# for n in np . arange ( nn ) : #NEWLINE# #INDENT# params = [ ( a + ( ( b - a ) * np . random . rand ( nparam ) ) ) for ( a , b ) in param_ranges ] #NEWLINE# params = np . asarray ( params ) . T #NEWLINE# if ( not param_ranges ) : #NEWLINE# #INDENT# params = [ 0 ] #NEWLINE# #UNINDENT# for p in params : #NEWLINE# #INDENT# if param_ranges : #NEWLINE# #INDENT# p = ( ( n , ) + tuple ( p ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# p = ( n , ) #NEWLINE# #UNINDENT# x = ( x_range [ 0 ] + ( ( x_range [ 1 ] - x_range [ 0 ] ) * np . random . rand ( nx ) ) ) #NEWLINE# x [ 0 ] = x_range [ 0 ] #NEWLINE# x [ 1 ] = x_range [ 1 ] #NEWLINE# kw = dict ( sig = ( ( ( len ( p ) + 1 ) * 'd' ) + '->d' ) ) #NEWLINE# z = np . c_ [ ( np . tile ( p , ( nx , 1 ) ) , x , func ( * ( p + ( x , ) ) , ** kw ) ) ] #NEWLINE# dataset . append ( z ) #NEWLINE# #UNINDENT# #UNINDENT# dataset = np . concatenate ( dataset , axis = 0 ) #NEWLINE# def polyfunc( * p ) : #NEWLINE# #INDENT# p = ( ( p [ 0 ] . astype ( int ) , ) + p [ 1 : ] ) #NEWLINE# kw = dict ( sig = ( ( 'l' + ( ( len ( p ) - 1 ) * 'd' ) ) + '->d' ) ) #NEWLINE# return func ( * p , ** kw ) #NEWLINE# #UNINDENT# olderr = np . seterr ( all = 'raise' ) #NEWLINE# try : #NEWLINE# #INDENT# ds = FuncData ( polyfunc , dataset , list ( range ( ( len ( param_ranges ) + 2 ) ) ) , ( - 1 ) , rtol = rtol ) #NEWLINE# ds . check ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# np . seterr ( ** olderr )