Re: [Numpy-discussion] casting integers to reals

2009-02-26 Thread Eric Firing
Gideon Simpson wrote: > I want to do: > > numpy.float(numpy.arange(0, 10)) > > but get the error: > > Traceback (most recent call last): >File "", line 1, in > TypeError: only length-1 arrays can be converted to Python scalars > > How should I do this? numpy.arange(0,10, dtype=float) or n

Re: [Numpy-discussion] casting integers to reals

2009-02-26 Thread Christopher Barker
Gael Varoquaux wrote: > nump.arange(0, 10.astype(numpy.float) I think you meant: np.arange(0, 10).astype(np.float) but: np.arange(0, 10, dtype=np.float) is a better bet. > but in this special case you can do: > > numpy.arange(0., 10.) yup -- however, beware, using arange() with floating poi

Re: [Numpy-discussion] casting integers to reals

2009-02-26 Thread Gael Varoquaux
On Thu, Feb 26, 2009 at 05:53:28PM -0500, Gideon Simpson wrote: > I want to do: > numpy.float(numpy.arange(0, 10)) > but get the error: > Traceback (most recent call last): >File "", line 1, in > TypeError: only length-1 arrays can be converted to Python scalars > How should I do this? nu

[Numpy-discussion] casting integers to reals

2009-02-26 Thread Gideon Simpson
I want to do: numpy.float(numpy.arange(0, 10)) but get the error: Traceback (most recent call last): File "", line 1, in TypeError: only length-1 arrays can be converted to Python scalars How should I do this? -gideon ___ Numpy-discussion mailin