[Numpy-discussion] Fwd: fill() function does not work.

Frank Lagor dfranci@seas.upenn....
Tue Nov 18 12:44:38 CST 2008


---------- Forwarded message ----------
From: Matthieu Brucher <matthieu.brucher@gmail.com>
Date: Tue, Nov 18, 2008 at 1:36 PM
Subject: Re: [Numpy-discussion] fill() function does not work.
To: Discussion of Numerical Python <numpy-discussion@scipy.org>


>From the docstring:

a.fill(value) -> None. Fill the array with the scalar value.

The method modifies the array, but does not return it.

Matthieu

2008/11/18 frank wang <f.yw@hotmail.com>:
> Hi,
>
> My numpy is 1.2.1 and python is 2.5.2.
>
> In python, I did:
>
> from numpy import *
> x=array([1,2,3])
> z=x.fill(x)
> print z
> None
>
> z should be filled with zero. I do not knwo why I got None. Can anyone help
> me on this?
>
> Thanks
>
> Frank
>
> ________________________________
> Proud to be a PC? Show the world. Download the "I'm a PC" Messenger
> themepack now. Download now.
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>

--
Information System Engineer, Ph.D.
Website: http://matthieu-brucher.developpez.com/
Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn: http://www.linkedin.com/in/matthieubrucher
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


For additional clarity:

you write x.fill(x), but this is not what you want because this would
take the first entry in x and fill the remainder of x with it.
Instead, you want x.fill(0).  Alternately, the function zeros is
useful.

-Frank


More information about the Numpy-discussion mailing list