Hi,

I try to update values in a single field of numpy record array based on 
a condition defined in another array. I found that that the result 
depends on the order in which I apply the boolean indices/field names.

For example:

cond = np.zeros(5, dtype=np.bool)
cond[2:] = True
X = np.rec.fromarrays([np.arange(5)], names='a')
X[cond]['a'] = -1
print X

returns:  [(0,) (1,) (2,) (3,) (4,)] (the values were not updated)

X['a'][cond] = -1
print X

returns: [(0,) (1,) (-1,) (-1,) (-1,)] (it worked this time).

I find this behaviour very confusing. Is it expected? Would it be 
possible to emit a warning message in the case of "faulty" assignments?

Bartosz
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to