[Numpy-tickets] [NumPy] #424: stable argsort() and sort() behave differently on 2-column uint64 arrays. possibly a bug in argsort() or sort() .

NumPy numpy-tickets@scipy....
Sun Apr 1 15:44:15 CDT 2007


#424: stable argsort() and sort() behave differently on 2-column uint64 arrays.
possibly a bug in argsort() or sort() .
------------------------+---------------------------------------------------
 Reporter:  ciro        |        Owner:  somebody     
     Type:  defect      |       Status:  new          
 Priority:  high        |    Milestone:  1.0.2 Release
Component:  numpy.core  |      Version:  1.0.1        
 Severity:  major       |   Resolution:               
 Keywords:              |  
------------------------+---------------------------------------------------
Old description:

> numpy 1.0.1 fails to pass the following
> in a reproducible way.
>
> =====================================================================
> #!/usr/bin/env python2.4
> from numpy import *
>

> N = 500000
> X = zeros((N,2), uint64)
>
> for i in range(N):
>    X[i,0] = random.randint(2**20) << 43      # if we set highest bit -
> problems
> #   X[i,0] = random.randint(2**20) << 42     # this works, instead
>

> X2 = X[:,0].copy()
> X2.sort(kind='mergesort')
>
> X_index = X[:,0].argsort(kind='mergesort')
> X[:,0] = take(X[:,0], X_index)
>
> print alltrue(X2 == X[:,0])
>
> ============================================================
>
> Conversely, the following always works:
>

>
> N = 500000
> X = zeros(N, uint64)
>
> for i in range(N):
>    X[i] = random.randint(2**20) << 43      # if we set highest bit, ok in
> this case
> #   X[i] = random.randint(2**20) << 42     # this works
>

> X2 = X.copy()
> X2.sort(kind='mergesort')
>
> X_index = X.argsort(kind='mergesort')
> X = take(X, X_index)
>
> print alltrue(X2 == X)
>
> ===================================================
>
> behavior seems inconsistent across architectures and numpy versions.

New description:

 numpy 1.0.1 fails to pass the following
 in a reproducible way.

 {{{
 #!/usr/bin/env python2.4
 from numpy import *


 N = 500000
 X = zeros((N,2), uint64)

 for i in range(N):
    X[i,0] = random.randint(2**20) << 43      # if we set highest bit -
 problems
 #   X[i,0] = random.randint(2**20) << 42     # this works, instead


 X2 = X[:,0].copy()
 X2.sort(kind='mergesort')

 X_index = X[:,0].argsort(kind='mergesort')
 X[:,0] = take(X[:,0], X_index)

 print alltrue(X2 == X[:,0])
 }}}

 Conversely, the following always works:

 {{{
 N = 500000
 X = zeros(N, uint64)

 for i in range(N):
    X[i] = random.randint(2**20) << 43      # if we set highest bit, ok in
 this case
 #   X[i] = random.randint(2**20) << 42     # this works


 X2 = X.copy()
 X2.sort(kind='mergesort')

 X_index = X.argsort(kind='mergesort')
 X = take(X, X_index)

 print alltrue(X2 == X)
 }}}

 behavior seems inconsistent across architectures and numpy versions.

Comment (by cookedm):

 I can't reproduce this (using a MacBook or an AMD64).

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/424#comment:1>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list