[Numpy-discussion] Casting scalars
Nathan Goldbaum
nathan12343 at gmail.com
Thu May 10 22:54:46 EDT 2018
On Thu, May 10, 2018 at 9:51 PM Stuart Reynolds <stuart at stuartreynolds.net>
wrote:
> np.float(scalar)
>
This actually isn't right. It's a common misconception, but np.float is an
alias to the built-in float type. You probably want np.float_(scalar)
In [5]: np.float_(12).dtype
Out[5]: dtype('float64')
In [6]: np.float is float
Out[6]: True
>
> On Thu, May 10, 2018 at 7:49 PM Hameer Abbasi <einstein.edison at gmail.com>
> wrote:
>
>> Hello, everyone!
>>
>> I might be missing something and this might be a very stupid and
>> redundant question, but is there a way to cast a scalar to a given dtype?
>>
>> Hameer
>>
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at python.org
>> https://mail.python.org/mailman/listinfo/numpy-discussion
>>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20180510/d3ce7727/attachment.html>
More information about the NumPy-Discussion
mailing list