#NEWLINE# def test_digitize( self ) : #NEWLINE# #INDENT# pyfunc = digitize #NEWLINE# cfunc = jit ( nopython = True ) ( pyfunc ) #NEWLINE# def check( * args ) : #NEWLINE# #INDENT# expected = pyfunc ( * args ) #NEWLINE# got = cfunc ( * args ) #NEWLINE# self . assertPreciseEqual ( expected , got ) #NEWLINE# #UNINDENT# values = np . float64 ( ( 0 , 0.99 , 1 , 4.4 , 4.5 , 7 , 8 , 9 , 9.5 , float ( 'inf' ) , float ( '-inf' ) , float ( 'nan' ) ) ) #NEWLINE# assert ( len ( values ) == 12 ) #NEWLINE# self . rnd . shuffle ( values ) #NEWLINE# bins1 = np . float64 ( [ 1 , 3 , 4.5 , 8 ] ) #NEWLINE# bins2 = np . float64 ( [ 1 , 3 , 4.5 , 8 , float ( 'inf' ) , float ( '-inf' ) ] ) #NEWLINE# bins3 = np . float64 ( ( [ 1 , 3 , 4.5 , 8 , float ( 'inf' ) , float ( '-inf' ) ] + ( [ float ( 'nan' ) ] * 10 ) ) ) #NEWLINE# if ( np_version >= ( 1 , 10 ) ) : #NEWLINE# #INDENT# all_bins = [ bins1 , bins2 , bins3 ] #NEWLINE# xs = [ values , values . reshape ( ( 3 , 4 ) ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# all_bins = [ bins1 , bins2 ] #NEWLINE# xs = [ values ] #NEWLINE# #UNINDENT# for bins in all_bins : #NEWLINE# #INDENT# bins . sort ( ) #NEWLINE# for x in xs : #NEWLINE# #INDENT# check ( x , bins ) #NEWLINE# check ( bins2 , bins [ : : ( - 1 ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# for bins in all_bins : #NEWLINE# #INDENT# bins . sort ( ) #NEWLINE# for right in ( True , False ) : #NEWLINE# #INDENT# check ( values , bins , right ) #NEWLINE# check ( values , bins [ : : ( - 1 ) ] , right ) #NEWLINE# #UNINDENT# #UNINDENT# check ( list ( values ) , bins1 )