[Numpy-discussion] sort method raises unexpected error with axis=None

Matthew Brett matthew.brett@gmail....
Wed Feb 13 14:48:20 CST 2008


Hi,

> Is it possible, in fact, to do an inplace sort on an array with
> axis=None (ie flat sort)?
>
> Should the sort method have its docstring changed to reflect the fact
> that axis=None is not valid?

Sorry to press on, but it would be good to resolve this somehow.

Is there some reason not to:

Suggestion 1:
Wrap the .sort method call in a tiny python wrapper of the form:

def sort(self, axis=-1, kind='quicksort', order=None):
    if axis=None:
       _c_sort(self.ravel(), axis, kind, order)
   else:
      _c_sort(self, axis, kind, order)

or 2:
Modify the method docstring to remove axis=None as valid option.

I'm happy to do either.

Matthew


More information about the Numpy-discussion mailing list