Suppose I have the following array:
a = np.array([0,1,0],
[1,0,0],
[0,0,1])
Would it be possible to do something like the this:
a[==0] = -1
to set all zeros to -1? I know you could something like the following to achieve the same effect:
b = a == 0
a[b] = -1
but I was just wondering if there was a way to skip the creation of the Boolean array for this.
2*a-1for such an array of 1s and 0s.