Ah, I see.  That rationale makes sense.

 

Paul

 

From: NumPy-Discussion 
<numpy-discussion-bounces+pwoodford=keywcorp....@python.org> on behalf of 
Marten van Kerkwijk <m.h.vankerkw...@gmail.com>
Reply-To: Discussion of Numerical Python <numpy-discussion@python.org>
Date: Tuesday, May 8, 2018 at 2:40 PM
To: Discussion of Numerical Python <numpy-discussion@python.org>
Subject: Re: [Numpy-discussion] sinc always returns double precision

 

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.], dtype=np.float32)).dtype

dtype('float32')

```

The rationale here is that for an array you generally do not want to

just blow up the memory usage, so its dtype has precedent (as long as

it is float). So, there is a reason, but it certainly leads to a lot

of confusion (e.g., 
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_numpy_numpy_issues_10322&d=DwICAg&c=31nHN1tvZeuWBT6LwDN4Ngk1qezfsYHyolgGeY2ZhlU&r=pWejSe2R2_qRF_nJUoy-IChkOn_Jf3D9EMavoc-oxtw&m=JujDdD-etvHDgctd0xXmVffN19AAT7Q9yD3Ryb71tnI&s=H4tN00ZUcDUwYLPau1NUGBTZbZ2HRfvFvzA0S8PB_Wc&e=)

 

All that said, the implementation of `np.sinc` is not super - really

could do with a few more in-place operations!

 

-- Marten

_______________________________________________

NumPy-Discussion mailing list

NumPy-Discussion@python.org

https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.python.org_mailman_listinfo_numpy-2Ddiscussion&d=DwICAg&c=31nHN1tvZeuWBT6LwDN4Ngk1qezfsYHyolgGeY2ZhlU&r=pWejSe2R2_qRF_nJUoy-IChkOn_Jf3D9EMavoc-oxtw&m=JujDdD-etvHDgctd0xXmVffN19AAT7Q9yD3Ryb71tnI&s=z-fzi6OPNJPWvVe8bgcB49TVJoosQJyusXcabEXXP0k&e=

 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to