Re: [Numpy-discussion] sinc always returns double precision

2018-05-10 Thread Paul Woodford
Ah, I see.  That rationale makes sense. Paul From: NumPy-Discussion on behalf of Marten van Kerkwijk Reply-To: Discussion of Numerical Python Date: Tuesday, May 8, 2018 at 2:40 PM To: Discussion of Numerical Python Subject: Re: [Numpy-discussion] sinc always returns double precision

Re: [Numpy-discussion] sinc always returns double precision

2018-05-08 Thread Marten van Kerkwijk
It is actually a bit more subtle (annoyingly so), the reason you get a float64 is that you pass in a scalar, and for scalars, the dtype of `pi` indeed "wins", as there is little reason to possibly loose precision. If you pass in an array instead, then you do get `float32`: ``` np.sinc(np.array([1.

[Numpy-discussion] sinc always returns double precision

2018-05-08 Thread Paul Woodford
Sinc seems to always return double precision, even when the input is single precision: In [125]: np.sinc(np.float32(0)).dtype Out[125]: dtype('float64') Is this desired behavior?  I’m guessing the promotion occurs in the multiplication by pi: y = pi * where(x == 0, 1.0e-20, x) Pa