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

Keith Goodman kwgoodman@gmail....
Fri Aug 29 12:55:07 CDT 2008


On Fri, Aug 29, 2008 at 10: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.

But python doesn't do that. For example, x.sort() returns None in
python. Should it return None in numpy?


More information about the Numpy-discussion mailing list