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

Matthew Brett matthew.brett@gmail....
Tue Feb 12 15:54:00 CST 2008


Hi,

To rephrase:

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?

Matthew

On Feb 10, 2008 7:50 PM, Matthew Brett <matthew.brett@gmail.com> wrote:
> Hi,
>
> I just noticed this:
>
> From the sort method docstring:
>
>     axis : integer
>         Axis to be sorted along. None indicates that the flattened array
>         should be used. Default is -1.
>
> In [40]: import numpy as N
>
> In [41]: a = N.arange(10)
>
> In [42]: N.sort(a, None)
> Out[42]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>
> In [43]: a.sort(None)
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
>
> /home/mb312/<ipython console> in <module>()
>
> TypeError: an integer is required
>
>
> Perhaps the sort method is calling the c code directly, and this is
> not checking for axis=None?
>
> Matthew
>


More information about the Numpy-discussion mailing list