#NEWLINE# def test_pack_mul( ) : #NEWLINE# #INDENT# def to_byte( vec ) : #NEWLINE# #INDENT# return np . clip ( ( vec * 255 ) , 0 , 255 ) . astype ( 'int32' ) #NEWLINE# #UNINDENT# X = ( ( np . random . randn ( 5 , 16 ) . astype ( 'float32' ) * 0.5 ) + 0.5 ) #NEWLINE# Y = run_code ( pack_mul , X ) #NEWLINE# Y = np . ndarray ( ( 5 , 16 ) , 'int32' , Y ) #NEWLINE# assert all ( ( np . abs ( ( to_byte ( X [ 0 ] ) - ( ( Y [ 0 ] >> 0 ) & 255 ) . astype ( 'int32' ) ) ) <= 1 ) ) #NEWLINE# assert all ( ( np . abs ( ( to_byte ( X [ 0 ] ) - ( ( Y [ 0 ] >> 8 ) & 255 ) . astype ( 'int32' ) ) ) <= 1 ) ) #NEWLINE# assert all ( ( np . abs ( ( to_byte ( X [ 0 ] ) - ( ( Y [ 0 ] >> 16 ) & 255 ) . astype ( 'int32' ) ) ) <= 1 ) ) #NEWLINE# assert all ( ( np . abs ( ( to_byte ( X [ 0 ] ) - ( ( Y [ 0 ] >> 24 ) & 255 ) . astype ( 'int32' ) ) ) <= 1 ) ) #NEWLINE# assert all ( ( np . abs ( ( to_byte ( X [ 1 ] ) - ( ( Y [ 1 ] >> 0 ) & 255 ) . astype ( 'int32' ) ) ) <= 1 ) ) #NEWLINE# assert all ( ( np . abs ( ( to_byte ( X [ 2 ] ) - ( ( Y [ 2 ] >> 8 ) & 255 ) . astype ( 'int32' ) ) ) <= 1 ) ) #NEWLINE# assert all ( ( np . abs ( ( to_byte ( X [ 3 ] ) - ( ( Y [ 3 ] >> 16 ) & 255 ) . astype ( 'int32' ) ) ) <= 1 ) ) #NEWLINE# assert all ( ( np . abs ( ( to_byte ( X [ 4 ] ) - ( ( Y [ 4 ] >> 24 ) & 255 ) . astype ( 'int32' ) ) ) <= 1 ) )