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

Frank Lagor dfranci at seas.upenn.edu
Tue Nov 18 13:44:38 EST 2008


---------- Forwarded message ----------
From: Matthieu Brucher <matthieu.brucher at 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 at 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 at 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 at 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 at 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