np.array loses dtype after integer division

Issue #35 resolved
Konstantin Lopukhin created an issue

CPython:

>>> import numpy as np
>>> np.__version__
'1.9.0'
>>> np.array(np.zeros(2), dtype=np.float32) / 2
array([ 0.,  0.], dtype=float32)

PyPy 2.6.0:

>>>> np.array(np.zeros(2), dtype=np.float32) / 2
array([ 0.,  0.])
>>>> _.dtype
dtype('float64')
>>>> 

This does not happen with float division.

Comments (2)

  1. Ronan Lamy

    This has already been fixed in PyPy's default branch. With any recent nightly, you should get:

    >>>> import numpy as np
    >>>> np.array(np.zeros(2), dtype=np.float32) / 2
    array([ 0.,  0.], dtype=float32)
    
  2. Log in to comment