[Numpy-discussion] isn't it a bug in array.fill()?

Charles R Harris charlesr.harris@gmail....
Fri Aug 29 13:01:07 CDT 2008


On Fri, Aug 29, 2008 at 11:51 AM, Keith Goodman <kwgoodman@gmail.com> wrote:

> On Fri, Aug 29, 2008 at 10:42 AM, dmitrey <dmitrey.kroshko@scipy.org>
> wrote:
> >
> > Keith Goodman wrote:
> >> Yeah, I do stuff like that too. fill works in place so it returns None.
> >>
> >>
> >>>> x = np.array([1,2])
> >>>> x.fill(10)
> >>>> x
> >>>>
> >>    array([10, 10])
> >>
> >>>> x = x.fill(10)  # <-- Danger!
> >>>> print x
> >>>>
> >> None
> >>
> > Since result "None" is never used it would be better to return reference
> > to the modified array, ...
>
> I like that idea. A lot of numpy functions return a reference to the
> modified array when the output array (out) is specified.


Google up the various discussions of python sort to see why Guido doesn't
like that sort of thing. We've had that discussion on this list also and
pretty much decided to follow python in these matters. Not that I really
agree with Guido here, but it's a small point and when in Rome...

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080829/59a2a494/attachment.html 


More information about the Numpy-discussion mailing list