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

Keith Goodman kwgoodman at gmail.com
Fri Aug 29 13:55:07 EDT 2008


On Fri, Aug 29, 2008 at 10:51 AM, Keith Goodman <kwgoodman at gmail.com> wrote:
> On Fri, Aug 29, 2008 at 10:42 AM, dmitrey <dmitrey.kroshko at 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