[Numpy-discussion] ndarray methods vs numpy module functions
Mon Jun 23 20:11:03 CDT 2008
On Mon, Jun 23, 2008 at 19:35, Ryan May <firstname.lastname@example.org> wrote:
> Robert Kern wrote:
>> On Mon, Jun 23, 2008 at 18:10, Sebastian Haase <email@example.com> wrote:
>>> On Mon, Jun 23, 2008 at 10:31 AM, Bob Dowling <firstname.lastname@example.org> 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
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion