help with TypeError
I am running this code def between(g): import distribution as di reload(di) btween = betweenness(g) v_btween = btween[0].get_array() e_btween = btween[1].get_array() v_dist = di.distribution(v_btween) e_dist = di.distribution(e_btween) print e_dist def distribution(inlist): import numpy as np x = np.array(inlist) c = np.bincount(x) y = np.nonzero(c)[0] value = y count = c[y] li = [value,count] return li and I am getting this error TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe' i tried dtype =np.int64 but then the values are getting rounded to 0 please help. ASAP -- http://about.me/shubham.bhushan
On 06/20/2014 10:50 AM, Shubham Bhushan wrote:
I am running this code def between(g): import distribution as di reload(di) btween = betweenness(g) v_btween = btween[0].get_array() e_btween = btween[1].get_array() v_dist = di.distribution(v_btween) e_dist = di.distribution(e_btween) print e_dist
def distribution(inlist): import numpy as np x = np.array(inlist) c = np.bincount(x) y = np.nonzero(c)[0] value = y count = c[y] li = [value,count] return li and I am getting this error TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'
i tried dtype =np.int64 but then the values are getting rounded to 0 please help. ASAP
I cannot help you if you don't provide a self-containing example which I can reproduce and shows exactly where the error occurs. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (2)
-
Shubham Bhushan -
Tiago de Paula Peixoto