Bug report

Peter Otten __peter__ at web.de
Wed Feb 24 16:15:19 EST 2021


On 24/02/2021 22:03, Dan Stromberg wrote:
> On Wed, Feb 24, 2021 at 12:58 PM Peter Otten <__peter__ at web.de> wrote:
> 
>> On 24/02/2021 20:36, Carla Molina wrote:
>> This is not a bug. Have a look at the array's dtype:
>>
>>   >>> n = 60461826
>>   >>> a = np.array([1, 50, 100, 150, 200, 250, 300])
>>   >>> a.dtype
>> dtype('int32')
>>
> I'm getting dtypes of float64.

When you run the snippet above or

> import numpy as np
> 
> NR = 0.25
> N = 60461826
> 
> initialINCIDENCE = np.array([1, 50, 100, 150, 200, 250, 300])
> initialINCIDENCE = initialINCIDENCE*N/(100000*7*NR)

here, i. e. after the division?

initialINCIDENCE*N

should be an int32 array, but dividing by

(100000*7*NR)

returns an dtype=float64 array. Switching back to my modified example:

 >>> a/42
array([0.02380952, 1.19047619, 2.38095238, 3.57142857, 4.76190476,
        5.95238095, 7.14285714])
 >>> _.dtype
dtype('float64')



More information about the Python-list mailing list