This is exactly what I needed! Thanks! On 11/05/2018 at 08:20, Warren
wrote: On Thu, May 10, 2018 at 10:53 PM, Hameer Abbasi
wrote: Yes, that I know. I meant given a
dtype string such as 'uint8' or a dtype object. I know I can possibly
do np.array(scalar, dtype=dtype)[()] but I was looking for a l
On Thu, May 10, 2018 at 10:53 PM, Hameer Abbasi
wrote:
> Yes, that I know. I meant given a dtype string such as 'uint8' or a
> dtype object. I know I can possibly do np.array(scalar,
> dtype=dtype)[()] but I was looking for a less hacky method.
Apparently the `dtype` object has the attribute `
On Thu, May 10, 2018 at 9:51 PM Stuart Reynolds
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
In [1]: import numpy as np
In [2]: np.float64(12)
Out[2]: 12.0
In [3]: np.float64(12).dtype
Out[3]: dtype('float64')
On Thu, May 10, 2018 at 9:49 PM Hameer Abbasi
wrote:
> Hello, everyone!
>
> I might be missing something and this might be a very stupid and redundant
> question, but is there a
Yes, that I know. I meant given a dtype string such as 'uint8' or a
dtype object. I know I can possibly do np.array(scalar,
dtype=dtype)[()] but I was looking for a less hacky method. On
11/05/2018 at 07:50, Stuart wrote: np.float(scalar) On Thu, May 10,
2018 at 7:49 PM Hameer Abbasi wrote:
Hello,
np.float(scalar)
On Thu, May 10, 2018 at 7:49 PM Hameer Abbasi
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
>
>
> _
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@python.org
https://mail.python.org/mail
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