On a numpy
array, why is it I can successfully use / 2
:
>>> a=np.array([2, 4, 6])
>>> a = a / 2
>>> a
array([ 1., 2., 3.])
But I cannot use a /= 2
?
>>> a=np.array([2, 4, 6])
>>> a /= 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: No loop matching the specified signature and casting
was found for ufunc true_divide
I've seen numpy Issue 6464, but don't understand from reading it and the linked release notes the reason this doesn't work.
Is there any way to get /=
to work as expected?
a
is a float. The second isn't allowed to change the dtype. – Glossolalia