[Numpy-discussion] Bizarre errors with byteswapping, complex256, PPC

Travis Oliphant travis@continuum...
Wed Jun 20 15:56:08 CDT 2012


This looks like a problem with comparisons of floating point numbers rather than a byteswapping problem per-say.   Try to use an almost equal comparison instead.  

-Travis

On Jun 20, 2012, at 3:48 PM, Matthew Brett wrote:

> Hi,
> 
> Our Debian friends were hammering our code tests before the upcoming
> freeze, and found the following very odd thing on 32-bit PPC running
> Debian squeeze and numpy 1.6.2 or current trunk.
> 
> Consider the following script:
> 
> <script>
> 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
> </script>
> 
> Here is the output from some example runs of this script:
> 
> 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]
> [ True False False False False False False False False False]
> [ True False False False False False False False False False]
> [ True False False False False False False False False False]
> 
> (that's the most common result)
> 
> (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]
> [ True  True  True  True  True  True  True  True  True  True]
> [ True  True  True  True  True  True  True  True  True  True]
> [ True  True  True  True  True  True  True  True  True  True]
> 
> (this happens maybe 10% of the time)
> 
> (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]
> [ True  True  True  True  True  True  True  True  True  True]
> [ True False False False False False False False False False]
> [ True  True  True  True  True  True  True  True  True  True]
> 
> (less than 10% of the time - order of True, False prints _of the same
> comparison_ is random.  This only seems to happen with complex256.
> 
> Is there anything I can do to debug this further?  Does anyone want a
> login to this machine to have a look?
> 
> See you,
> 
> Matthew
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list