[Numpy-discussion] ndarray methods vs numpy module functions
Stéfan van der Walt
Tue Jun 24 03:39:17 CDT 2008
2008/6/24 Bob Dowling <email@example.com>:
> I would make a plea for consistency, to start with.
> Those of us who write in an OO style are required to switch backwards
> and forwards between OO and not-OO, or to abandon OO altogether in our
> NumPy code. Neither is an attractive option.
There are an infinite number of operations to be performed on arrays,
so the question becomes: which of those belong as members of the
class? In my opinion, none do; we have them simply for backward
In general, my feeling (not the status quo) is to:
a) Use array methods for in-place operations and operations pertaining
specifically to ndarrays. This would include `sort`, but not `sum` or
b) Use numpy functions for operations that copy the object, or do
calculations that yield new objects.
Even if you subscribe to such a rule, having x.sum() at hand is
convenient, so many people use it. There's bound to be a big outcry
if we try to remove them now. I'm not even sure most people would
agree with these guidelines.
More information about the Numpy-discussion