[Numpy-discussion] Adding an axis argument to numpy.unique
Nathaniel Smith
njs@pobox....
Tue Aug 20 06:55:47 CDT 2013
On 20 Aug 2013 12:53, <josef.pktd@gmail.com> wrote:
>
> On Tue, Aug 20, 2013 at 7:47 AM, <josef.pktd@gmail.com> wrote:
> > On Tue, Aug 20, 2013 at 7:34 AM, Nathaniel Smith <njs@pobox.com> wrote:
> >> On 20 Aug 2013 12:09, <josef.pktd@gmail.com> wrote:
> >>>
> >>> On Tue, Aug 20, 2013 at 5:04 AM, Nathaniel Smith <njs@pobox.com>
wrote:
> >>> > On 20 Aug 2013 01:39, "Joe Kington" <joferkington@gmail.com> wrote:
> >>> >>
> >>> >>
> >>> >>
> >>> >>
> >>> >> ...<snip>
> >>> >>>
> >>> >>>
> >>> >>> However, my first interpretation of an axis argument in unique
would
> >>> >>> be that it treats each column (or whatever along axis) separately.
> >>> >>> Analogously to max, argmax and similar.
> >>> >>
> >>> >>
> >>> >> Good point!
> >>> >>
> >>> >> That's certainly a potential source of confusion. However, I can't
> >>> >> seem
> >>> >> to come up with a better name for the kwarg. Matlab's "unique"
function
> >>> >> has
> >>> >> a "rows" option, which is probably a more intuitive name, but
doesn't
> >>> >> imply
> >>> >> the expansion to N-dimensions.
> >>> >>
> >>> >> "axis" is still fairly idiomatic, despite the confusion over
"unique
> >>> >> rows/columns/etc" vs "unique items within each row/column/etc".
> >>> >>
> >>> >> Any thoughts on a better name for the argument?
> >>> >
> >>> > I also found this pretty confusing when first looking at the PR.
> >>> >
> >>> > One option might be to invert the sense of the argument to emphasize
> >>> > that
> >>> > it's treating subarrays as units, so instead of specifying the
iteration
> >>> > axis you specify the axes of the subarray. compare_axis= or
something?
> >>>
> >>> you would need compare_axes (plural for ndim>2) and have to specify
> >>> all but one axis, AFAICS.
> >>
> >> Well, it makes sense to specify any arbitrary subset of axes, whether
or not
> >> that's currently implemented.
> >
> > not AFAICS, if you want to return a rectangular array without
> > nans/missing values.
>
> and unless you want to ravel() the remaining axis, which is also weird
> (I think).
The default (and until this patch, only) behaviour is to ravel all axes, so
it'd be consistent.
-n
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130820/64ae4678/attachment.html
More information about the NumPy-Discussion
mailing list