Discussion:
[Numpy-discussion] Axis argument to np.unique
Martino Sorbaro
2016-06-15 13:16:36 UTC
Permalink
Hi all,
I've opened a new pull request
(https://github.com/numpy/numpy/pull/7742) trying to revive a previous
one that was left abandoned (#3584, by another contributor), regarding
the possibility of adding an 'axis=' argument to numpy.unique.

There had been a debate
(http://numpy-discussion.10968.n7.nabble.com/Adding-an-axis-argument-to-numpy-unique-td34841.html)
about what the axis argument should mean. The current behaviour in the
code I propose (written by the previous contributor) looks for unique
rows if "axis=0" and unique columns if "axis=1", in other words:

[In] a = array([[0, 0, 0],
[1, 1, 1],
[0, 0, 0]])

[In] unique(a, axis=0)
[Out] array([[0, 0, 0],
[1, 1, 1]])


So, I would just like to ask whether a conclusion can be reached about
that discussion.
Thanks!
Martino
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
Benjamin Root
2016-06-15 13:31:56 UTC
Permalink
That seems like the only reasonable behavior, but I will admit that my
initial desire is essentially a vectorized "unique" such that it returns
the unique values of the stated axis. But that isn't possible because there
can be different number of unique values in the given axis, resulting in a
ragged array, which numpy does not support.

Ben Root
Post by Martino Sorbaro
Hi all,
I've opened a new pull request
(https://github.com/numpy/numpy/pull/7742) trying to revive a previous
one that was left abandoned (#3584, by another contributor), regarding
the possibility of adding an 'axis=' argument to numpy.unique.
There had been a debate
(
http://numpy-discussion.10968.n7.nabble.com/Adding-an-axis-argument-to-numpy-unique-td34841.html
)
about what the axis argument should mean. The current behaviour in the
code I propose (written by the previous contributor) looks for unique
[In] a = array([[0, 0, 0],
[1, 1, 1],
[0, 0, 0]])
[In] unique(a, axis=0)
[Out] array([[0, 0, 0],
[1, 1, 1]])
So, I would just like to ask whether a conclusion can be reached about
that discussion.
Thanks!
Martino
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Loading...