[SciPy-Dev] review request - test noise clean up

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Jan 12 08:05:30 EST 2011


On Wed, Jan 12, 2011 at 5:49 AM, Pauli Virtanen <pav at iki.fi> wrote:
> Wed, 12 Jan 2011 18:18:12 +0800, Ralf Gommers wrote:
>> https://github.com/rgommers/scipy/commit/fdf18166. They were calls to
>> fblas funcs with the wrong dtype, obscured a bit by subclassing the test
>> classes. So the only ones left are for ndarray.astype(), which should be
>> fixed in numpy.
>
> np.array(1+2j).astype(np.float64)
>
> IMHO should still raise a ComplexWarning. Cast, even explicit, from
> complex to float should strictly speaking be undefined. One should do
>
> np.array(1+2j).real.astype(np.float64)

Isn't .astype always an explicit request to (down)cast ?

np.array(1.).astype(int)
np.array(1+2j).astype(int)

I don't think numpy has any other function that casts to int for
example. (round to closest integer and cast)

Just for consistency of astype, astype looks a bit dangerous to use
for downcasting, as substitute for real_if_close.

Josef



>
> to be explicit.
>
> --
> Pauli Virtanen
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>



More information about the SciPy-Dev mailing list