Hi, 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?. Matthew
On 12 Feb 2008, at 12:31, Matthew Brett wrote:
def median(a, axis=0, out=None) (same signature as max, min etc)
I would be slightly in favour of this option. Using the same signature would be convenient in code like def myfunc(myarray, somefunc): # do stuff ... x = somefunc(myarray, axis = 0, out = None) # do more stuff ... where somefunc could be median(), mean(), max(), min(), std() etc. I once wrote this kind of function to provide (small) image filtering. If the same signature is used, there is no need to special-case median(). I realise it's kind of a niche example, though. Just my 0.02 euros. Joris Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
On Feb 12, 2008 6:33 AM, Joris De Ridder <Joris.DeRidder@ster.kuleuven.be> wrote:
On 12 Feb 2008, at 12:31, Matthew Brett wrote:
def median(a, axis=0, out=None) (same signature as max, min etc)
I would be slightly in favour of this option. Using the same signature would be convenient in code like
def myfunc(myarray, somefunc):
# do stuff ... x = somefunc(myarray, axis = 0, out = None)
# do more stuff ...
where somefunc could be median(), mean(), max(), min(), std() etc. I once wrote this kind of function to provide (small) image filtering. If the same signature is used, there is no need to special-case median(). I realise it's kind of a niche example, though.
I'm happy with that use case. The docstring should mention that out= is not memory-optimized like it is for the others, though. -- Robert Kern "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
On 12/02/2008, Matthew Brett <matthew.brett@gmail.com> wrote:
Suggestion 1: def median(a, axis=0, out=None) [...] Suggestion 2: def median(a, axis=0, scratch_input=False)
No reason not to combine the two. It's a pretty straightforward modification to do the sorting in place, and it could make a lot more difference to the runtime (and memory usage) than an output array. Anne
Hi, On Feb 12, 2008 8:48 PM, Anne Archibald <peridot.faceted@gmail.com> wrote:
On 12/02/2008, Matthew Brett <matthew.brett@gmail.com> wrote:
Suggestion 1: def median(a, axis=0, out=None) [...] Suggestion 2: def median(a, axis=0, scratch_input=False)
No reason not to combine the two. It's a pretty straightforward modification to do the sorting in place, and it could make a lot more difference to the runtime (and memory usage) than an output array.
Yes, true. I'll include it unless anyone pipes up to object. Matthew
On Tue, Feb 12, 2008 at 09:09:11PM +0000, Matthew Brett wrote:
Suggestion 1: def median(a, axis=0, out=None) [...] Suggestion 2: def median(a, axis=0, scratch_input=False)
No reason not to combine the two. It's a pretty straightforward modification to do the sorting in place, and it could make a lot more difference to the runtime (and memory usage) than an output array.
Yes, true. I'll include it unless anyone pipes up to object.
Scratch_input is not clear at all for me. I would suggest "inplace" rather. Gaƫl
participants (5)
-
Anne Archibald -
Gael Varoquaux -
Joris De Ridder -
Matthew Brett -
Robert Kern