[Numpy-discussion] numarray.fromfunction and Float32
Todd Miller
jmiller at stsci.edu
Sat Mar 8 03:56:06 EST 2003
Sebastian Haase wrote:
>Hi,
>I am just looking into numarray.fromfuntion.
>I have e.g. this:
>
>def func(x,y,z):
> return 1.2*(x+y+z)
>
>a = na.fromfunction(func, (nz,ny,nx))
>b = a.astype(na.Float32)
>
>Is there a way to tell fromfunction to _directly_ generate a Float32 typed
>array.
>
I don't think so. Numeric does not have this capability either,
although it appears easy enough to add it.
>As I see it only "standard" Python type are possible now.
>Or: Is there a scalar conversion function like numarray.Float32( 3.141 ) ?
>
You can create rank-0 numarrays which are essentially typed scalars;
these are not, however, widely used.
>>> import numarray
>>> a = numarray.array(3.141, type=numarray.Float32)
>
>Thanks,
>Sebastian Haase
>
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger
>for complex code. Debugging C/C++ programs can leave you feeling lost and
>disoriented. TotalView can help you find your way. Available on major UNIX
>and Linux platforms. Try it free. www.etnus.com
>_______________________________________________
>Numpy-discussion mailing list
>Numpy-discussion at lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
More information about the NumPy-Discussion
mailing list