[Numpy-discussion] Median advice

Matthew Brett matthew.brett@gmail....
Tue Feb 12 05:31:17 CST 2008


I'm just doing the median implementation.

This is just to pull together a couple of threads, about what the call
signature, behavior should be.

We've already established that we're going to leave the default
behavior of taking the median over the first axis, even though it
differs from that of max, min, mean etc - for compatibility - and
change to axis=None (flatten) behavior around v1.1 to harmonize with
the others.

Suggestion 1:
def median(a, axis=0, out=None)

(same signature as max, min etc)
Problem - there is no memory saving implementation in median at the
moment for the out= argument.  It's possible to imagine one, but it
would be a little annoying to code.  Should we put this in the
signature, behavior without memory-saving in order to make space for a
memory saving implementation in the future?

Suggestion 2:
def median(a, axis=0, scratch_input=False)

Here, according to a suggestion by Anne A - we could allow the routine
to use the input matrix a as scratch space to calculate the median,
saving memory if the user does not need to preserve the values of a.
a would be in an undefined state on return.

Any votes, thoughts?.


More information about the Numpy-discussion mailing list