#NEWLINE# def test_roots_croots( self ) : #NEWLINE# #INDENT# np . random . seed ( 1234 ) #NEWLINE# for k in range ( 1 , 15 ) : #NEWLINE# #INDENT# c = np . random . rand ( k , 1 , 130 ) #NEWLINE# if ( cres == 3 ) : #NEWLINE# #INDENT# c [ : , 0 , 0 ] = ( 1 , 2 , 1 ) #NEWLINE# #UNINDENT# for y in [ 0 , np . random . random ( ) ] : #NEWLINE# #INDENT# w = np . empty ( c . shape , dtype = complex ) #NEWLINE# _ppoly . _croots_poly1 ( c , w ) #NEWLINE# if ( k == 1 ) : #NEWLINE# #INDENT# assert_ ( np . isnan ( w ) . all ( ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# res = 0 #NEWLINE# cres = 0 #NEWLINE# for i in range ( k ) : #NEWLINE# #INDENT# res += ( c [ ( i , None ) ] * ( w ** ( ( k - 1 ) - i ) ) ) #NEWLINE# cres += abs ( ( c [ ( i , None ) ] * ( w ** ( ( k - 1 ) - i ) ) ) ) #NEWLINE# #UNINDENT# with np . errstate ( invalid = 'ignore' ) : #NEWLINE# #INDENT# res /= cres #NEWLINE# #UNINDENT# res = res . ravel ( ) #NEWLINE# res = res [ ( ~ np . isnan ( res ) ) ] #NEWLINE# assert_allclose ( res , 0 , atol = 1e-10 )