Re: [Numpy-discussion] Casting scalars

2018-05-10 Thread Hameer Abbasi
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,

Re: [Numpy-discussion] Casting scalars

2018-05-10 Thread Warren Weckesser
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

Re: [Numpy-discussion] Casting scalars

2018-05-10 Thread Nathan Goldbaum
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]:

Re: [Numpy-discussion] Casting scalars

2018-05-10 Thread Nathan Goldbaum
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

Re: [Numpy-discussion] Casting scalars

2018-05-10 Thread Hameer Abbasi
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

[Numpy-discussion] Casting scalars

2018-05-10 Thread Hameer Abbasi
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

Re: [Numpy-discussion] sinc always returns double precision

2018-05-10 Thread Paul Woodford
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