[Numpy-discussion] dtyping with .astype()
josef.pktd at gmail.com
josef.pktd at gmail.com
Mon Oct 17 13:04:44 EDT 2011
On Mon, Oct 17, 2011 at 10:18 AM, Pauli Virtanen <pav at iki.fi> wrote:
> 17.10.2011 15:48, josef.pktd at gmail.com kirjoitti:
>> On Mon, Oct 17, 2011 at 6:17 AM, Pauli Virtanen <pav at iki.fi> wrote:
> [clip]
>>>> What am I missing? How to do this?
>>>
>>> np.rec.fromarrays(arr.T, dtype=dt)
>>
>> y.astype(float16).view(dt)
>
> I think this will give surprises if the original array is not in C-order.
I forgot about those, dangerous if the array is square, otherwise it
raises an error if it is in F-order
maybe
np.asarray(y, np.float16, order='C').view(dt)
if I don't like record arrays
Josef
>
> Pauli
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list