consider the following Python code:
import numpy
a = numpy.random.rand(3,4)
b = numpy.random.rand(3,4)
c = a
c += b
c/2. - (a + b)/2.
The result of the last line is not an array with zeros. However, if I do:
d = a
d = d + b
d/2. - (a + b)/2.
Then the result is 0, as expected. This looks strange to me, can anybody please explain this behaviour? Is it wise to use +=, /=, ...
for numpy arrays at all? Thank you!
(This is only a minimal example, I have to add up several arrays.)