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

Charles R Harris charlesr.harris at gmail.com
Wed Jun 20 18:08:04 EDT 2012


On Wed, Jun 20, 2012 at 2:48 PM, Matthew Brett <matthew.brett at gmail.com>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 at 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 at 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 at 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?
>

Try swapped float128 and see what that looks like.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120620/1bc8db9f/attachment.html>


More information about the NumPy-Discussion mailing list