[NumPy-Tickets] [NumPy] #2174: Byteswapped complex256 on Debian PPC randomly incorrect subtraction

NumPy Trac numpy-tickets@scipy....
Wed Jun 20 17:42:13 CDT 2012


#2174: Byteswapped complex256 on Debian PPC randomly incorrect subtraction
---------------------------+------------------------------------------------
 Reporter:  matthew.brett  |       Owner:  somebody   
     Type:  defect         |      Status:  new        
 Priority:  normal         |   Milestone:  Unscheduled
Component:  numpy.core     |     Version:  devel      
 Keywords:                 |  
---------------------------+------------------------------------------------
 PPC 32-bit on Debian Wheezy, numpy 1.6.2 and current numpy trunk:

 {{{
     In [2]: np.__version__
     Out[2]: '1.7.0.dev-651ef74'
 }}}

 {{{
 import numpy as np

 arr = np.arange(10, dtype=np.complex256)
 bs_arr = arr.byteswap().newbyteorder('S')
 print arr
 print bs_arr
 print arr - bs_arr
 print arr - bs_arr
 print arr - bs_arr
 }}}

 The result of subtraction is wrong most (~90%) of the time; with the
 byteswapped array acting as if it is all zeros.

 {{{
 (np-devel)[mb312@joshlegacy ~/tmp]$ python funny_bs.py
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
  7.0+0.0j  8.0+0.0j  9.0+0.0j]
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
  7.0+0.0j  8.0+0.0j  9.0+0.0j]
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
  7.0+0.0j  8.0+0.0j  9.0+0.0j]
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
  7.0+0.0j  8.0+0.0j  9.0+0.0j]
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
  7.0+0.0j  8.0+0.0j  9.0+0.0j]
 }}}

 About 10% of the time the arrays appear to behave correctly:

 {{{
 (np-devel)[mb312@joshlegacy ~/tmp]$ python funny_bs.py
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
  7.0+0.0j  8.0+0.0j  9.0+0.0j]
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
  7.0+0.0j  8.0+0.0j  9.0+0.0j]
 [ 0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j
  0.0+0.0j  0.0+0.0j  0.0+0.0j]
 [ 0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j
  0.0+0.0j  0.0+0.0j  0.0+0.0j]
 [ 0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j
  0.0+0.0j  0.0+0.0j  0.0+0.0j]
 }}}


 More rarely there is a mix of incorrect and correct. Notice below that the
 first pass of `arr - bs_arr` is incorrect, and the second and third repeat
 of exactly the same statement on the same variables are correct.

 {{{
 (np-devel)[mb312@joshlegacy ~/tmp]$ python funny_bs.py
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
   7.0+0.0j  8.0+0.0j  9.0+0.0j]
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
   7.0+0.0j  8.0+0.0j  9.0+0.0j]
 [ 0.0+0.0j  1.0+0.0j  2.0+0.0j  3.0+0.0j  4.0+0.0j  5.0+0.0j  6.0+0.0j
   7.0+0.0j  8.0+0.0j  9.0+0.0j]
 [ 0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j
   0.0+0.0j  0.0+0.0j  0.0+0.0j]
 [ 0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j  0.0+0.0j
   0.0+0.0j  0.0+0.0j  0.0+0.0j]
 }}}

 Float128 and other numpy dtypes appear to be correct.

 I'm happy to give access to this machine if someone needs to debug.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/2174>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list