python - NumPy array acts differently based on origin (np.max() and np.argmax()) -


i have function creates numpy array data file. want maximum value in array , index of value:

import numpy np def dostuff():     # open .txt file lists     # copy lists numpy array     # nested loops , values copied numpy array called      print     print np.max(a)     print np.argmax(a)  dostuff() 

running gives:

[[  0.64   0.47   0.22   0.1    0.05   0.02] [  2.19   9.13  10.68   6.44   3.36   1.77] [  1.84   8.81  12.6    8.31   4.45   2.35]] 2.35 0 

clearly has gone wrong np.max() , np.argmax(). can shown following code

def test():     = np.array([[0.64, 0.47, 0.22, 0.1, 0.05, 0.02],                 [2.19, 9.13, 10.68, 6.44, 3.36, 1.77],                 [1.84, 8.81, 12.6, 8.31, 4.45, 2.35]])      print     print np.max(a)     print np.argmax(a) test() 

this gives:

[[  0.64   0.47   0.22   0.1    0.05   0.02] [  2.19   9.13  10.68   6.44   3.36   1.77] [  1.84   8.81  12.6    8.31   4.45   2.35]] 12.6 14 

...which have expected. have no idea why these 2 (apparently) identical arrays give different results here. know may have done?


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -