3

So.. I'm confused. Was it always this way? I've lost an hour trying to find who the hell was reiniting my array after I added a float array.

>>> import numpy as np
>>> a = np.array([1,2])
>>> a
array([1, 2])
>>> a += [0.1, 0.1]
>>> a
array([1, 2])
>>> a += np.array([0.1, 0.1])
>>> a
array([1, 2])
>>> a += np.array([0.1, 0.1])
>>> a
array([1, 2])
>>> a = a + [0.1, 0.1]
>>> a
array([ 1.1,  2.1])
>>> a = np.array([1,2]).astype(float)
>>> a += [0.1,0.2]
>>> a
array([ 1.1,  2.2])

EDIT: Well, this was totally unexpected. My life will never be the same and I will start making lots of float arrays now.

userqwerty1
  • 887
  • 2
  • 9
  • 23

0 Answers0