[NumPy-Tickets] [NumPy] #2063: unique() does not seem to return correct index if array larger than 16

NumPy Trac numpy-tickets@scipy....
Sat Mar 3 07:35:40 CST 2012


#2063: unique() does not seem to return correct index if array larger than 16
------------------------+---------------------------------------------------
 Reporter:  lolowizard  |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  highest     |   Milestone:  1.7.0   
Component:  numpy.core  |     Version:  1.6.1   
 Keywords:  unique      |  
------------------------+---------------------------------------------------
Changes (by rgommers):

  * milestone:  1.6.2 => 1.7.0


Old description:

> Unique seem to return the index of the last occurence rather than first
> occurence if len(array)>16
>
> To reproduce:
> v=[0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2]
> w=[0,0,0,0,0,1,1,1,1,1,1,2,2,2,2]
>
> Only difference between v and w is the two extra values at the end.
>
> Then:
> unique(v,return_index=True)
> unique(w,return_index=True)
>
> Look at the results for both commands:
>
> (array([0, 1, 2]), array([ 0, 10, 15]))
>
> (array([0, 1, 2]), array([0, 5, 9]))
>
> The two commands should return the same index!

New description:

 Unique seem to return the index of the last occurence rather than first
 occurence if len(array)>16

 To reproduce:
 {{{
 v=[0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2]
 w=[0,0,0,0,0,1,1,1,1,1,1,2,2,2,2]
 }}}
 Only difference between v and w is the two extra values at the end.

 Then:
 {{{
 unique(v,return_index=True)
 unique(w,return_index=True)
 }}}
 Look at the results for both commands:
 {{{
 (array([0, 1, 2]), array([ 0, 10, 15]))

 (array([0, 1, 2]), array([0, 5, 9]))
  }}}
 The two commands should return the same index!

--

Comment:

 <reformatted description>
 you can enclose code in triple curly brackets, no need to attach a png.

 Looks like a serious bug, should be fixed for the next release.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/2063#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list