[Numpy-discussion] ndarray methods vs numpy module functions

Sebastian Haase haase@msg.ucsf....
Tue Jun 24 02:43:52 CDT 2008

On Tue, Jun 24, 2008 at 3:11 AM, Robert Kern <robert.kern@gmail.com> wrote:
> On Mon, Jun 23, 2008 at 19:35, Ryan May <rmay31@gmail.com> wrote:
>> Robert Kern wrote:
>>> On Mon, Jun 23, 2008 at 18:10, Sebastian Haase <haase@msg.ucsf.edu> wrote:
>>>> On Mon, Jun 23, 2008 at 10:31 AM, Bob Dowling <rjd4@cam.ac.uk> wrote:
>>>>> [ I'm new here and this has the feel of an FAQ but I couldn't find
>>>>> anything at http://www.scipy.org/FAQ .  If I should have looked
>>>>> somewhere else a URL would be gratefully received. ]
>>>>> What's the reasoning behind functions like sum() and cumsum() being
>>>>> provided both as module functions (numpy.sum(data, axis=1)) and as
>>>>> object methods (data.sum(axis=1)) but other functions - and I stumbled
>>>>> over diff() - only being provided as module functions?
>>>> Hi Bob,
>>>> this is a very good question.
>>>> I think the answers are
>>>> a) historical reasons AND, more importantly, differing personal preferences
>>>> b) I would file  the missing data.diff() as a bug.
>>> It's not.
>> Care to elaborate?
> There is not supposed to be a one-to-one correspondence between the
> functions in numpy and the methods on an ndarray. There is some
> duplication between the two, but that is not a reason to make more
> duplication.
Are you saying the duplication is "just random" ?  It would be better
-- as in: principle of minimum surprise -- if there would be some sort
"reasonable set" of duplicates ....
If there are only a handful functions missing, why not try to make it complete.

( Again, a list of functions vs. methods on the wiki would clarify
what we are talking about ....)

Just thinking loudly of course. Don't take this as an offense .....

More information about the Numpy-discussion mailing list