[SCM] Core functionality for performing astronomy and astrophysics with Python branch, debian, updated. ea2921e83ee92928fe49b44097e613d41c11c982

Ole Streicher debian at liska.ath.cx
Mon Apr 22 17:57:06 UTC 2013


The following commit has been merged in the debian branch:
commit ea2921e83ee92928fe49b44097e613d41c11c982
Author: Ole Streicher <debian at liska.ath.cx>
Date:   Mon Apr 22 19:38:34 2013 +0200

    Fix FTBS (unit test failure) on bigendian machines

diff --git a/debian/changelog b/debian/changelog
index c7ae20a..7452233 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+python-astropy (0.2.1-1~exp5) experimental; urgency=low
+
+  * Fix FTBS (unit test failure) on bigendian machines
+
+ -- Ole Streicher <debian at liska.ath.cx>  Mon, 22 Apr 2013 19:37:00 +0200
+
 python-astropy (0.2.1-1~exp4) experimental; urgency=low
 
   * Fix FTBS (unit test failure) on Hurd
diff --git a/debian/patches/fix_bigendian_ftbs.patch b/debian/patches/fix_bigendian_ftbs.patch
new file mode 100644
index 0000000..62613aa
--- /dev/null
+++ b/debian/patches/fix_bigendian_ftbs.patch
@@ -0,0 +1,166 @@
+Author: Michael Droettboom <mdboom at gmail.com>
+Description: Fix a number of byteswapping bugs
+ I hope this will fix #963.
+ .
+ I have tested it under qemu ppc emulation with Debian 6 using the system
+ Python 2.6, and pip-installed Numpy 1.7.1 (testing Numpy 1.4.1 has too many
+ limitations).
+Url: https://github.com/astropy/astropy/pull/1003
+Bug: https://github.com/astropy/astropy/issues/963
+--- a/astropy/io/fits/hdu/compressed.py
++++ b/astropy/io/fits/hdu/compressed.py
+@@ -1216,13 +1216,6 @@
+             self.shape != self.data.shape):
+             self.updateHeaderData(self.header)
+ 
+-        # put data in machine native byteorder on little endian machines
+-        # for handing off to the compression code
+-        if sys.byteorder == 'little':
+-            swap_types = ('>',)
+-        else:
+-            swap_types = ('>', '=')
+-
+         # TODO: This is copied right out of _ImageBaseHDU._writedata_internal;
+         # it would be cool if we could use an internal ImageHDU and use that to
+         # write to a buffer for compression or something. See ticket #88
+@@ -1232,24 +1225,23 @@
+             # Convert the unsigned array to signed
+             self.data = np.array(
+                 self.data - _unsigned_zero(self.data.dtype),
+-                dtype='<i%d' % self.data.dtype.itemsize)
++                dtype='=i%d' % self.data.dtype.itemsize)
+             should_swap = False
+         else:
+-            byteorder = self.data.dtype.str[0]
+-            should_swap = (byteorder in swap_types)
++            should_swap = not self.data.dtype.isnative
+ 
+         if should_swap:
+             self.data.byteswap(True)
+ 
+-        nrows = self._header['NAXIS2']
+-        tbsize = self._header['NAXIS1'] * nrows
++        try:
++            nrows = self._header['NAXIS2']
++            tbsize = self._header['NAXIS1'] * nrows
+ 
+-        self._header['PCOUNT'] = 0
+-        if 'THEAP' in self._header:
+-            del self._header['THEAP']
+-        self._theap = tbsize
++            self._header['PCOUNT'] = 0
++            if 'THEAP' in self._header:
++                del self._header['THEAP']
++            self._theap = tbsize
+ 
+-        try:
+             # Compress the data.
+             # The current implementation of compress_hdu assumes the empty
+             # compressed data table has already been initialized in
+--- a/astropy/io/votable/converters.py
++++ b/astropy/io/votable/converters.py
+@@ -8,6 +8,7 @@
+ 
+ # STDLIB
+ import re
++import sys
+ from struct import unpack as struct_unpack
+ from struct import pack as struct_pack
+ 
+@@ -41,6 +42,18 @@
+ _zero_byte = b'\0'
+ 
+ 
++if sys.byteorder == 'little':
++    def _ensure_bigendian(x):
++        if x.dtype.byteorder != '>':
++            return x.byteswap()
++        return x
++else:
++    def _ensure_bigendian(x):
++        if x.dtype.byteorder == '<':
++            return x.byteswap()
++        return x
++
++
+ def _make_masked_array(data, mask):
+     """
+     Masked arrays of zero length that also have a mask of zero length
+@@ -517,8 +530,7 @@
+ 
+     def binoutput(self, value, mask):
+         filtered = self._base.filter_array(value, mask)
+-        if filtered.dtype.byteorder != '>':
+-            filtered = filtered.byteswap()
++        filtered = _ensure_bigendian(filtered)
+         return filtered.tostring()
+ 
+ 
+@@ -637,8 +649,7 @@
+         if mask:
+             return self._null_binoutput
+ 
+-        if value.dtype.byteorder != '>':
+-            value = value.byteswap()
++        value = _ensure_bigendian(value)
+         return value.tostring()
+ 
+     def _filter_nan(self, value, mask):
+@@ -721,8 +732,8 @@
+                 vo_raise(W31)
+             else:
+                 value = self.null
+-        if value.dtype.byteorder != '>':
+-            value = value.byteswap()
++
++        value = _ensure_bigendian(value)
+         return value.tostring()
+ 
+     def filter_array(self, value, mask):
+--- a/astropy/io/votable/tests/vo_test.py
++++ b/astropy/io/votable/tests/vo_test.py
+@@ -97,7 +97,7 @@
+         _debug_python_based_parser=_python_based)
+     table = votable.get_first_table()
+ 
+-    assert table.array.dtype == [
++    dtypes = [
+         (('string test', 'string_test'), '|O8'),
+         (('fixed string test', 'string_test_2'), '|S10'),
+         ('unicode_test', '|O8'),
+@@ -127,6 +127,14 @@
+         ('doublearray', '|O8'),
+         ('bitarray2', '|b1', (16,))
+         ]
++    if sys.byteorder == 'big':
++        new_dtypes = []
++        for dtype in dtypes:
++            dtype = list(dtype)
++            dtype[1] = dtype[1].replace('<', '>')
++            new_dtypes.append(tuple(dtype))
++        dtypes = new_dtypes
++    assert table.array.dtype == dtypes
+ 
+     votable.to_xml(join(TMP_DIR, "regression.tabledata.xml"),
+                    _debug_python_based_parser=_python_based)
+--- a/astropy/table/tests/test_row.py
++++ b/astropy/table/tests/test_row.py
+@@ -1,4 +1,6 @@
+ # Licensed under a 3-clause BSD style license - see LICENSE.rst
++import sys
++
+ from distutils import version
+ import numpy as np
+ 
+@@ -62,7 +64,10 @@
+         assert row.columns is table.columns
+         with pytest.raises(IndexError):
+             row[2]
+-        assert str(row.dtype) == "[('a', '<i8'), ('b', '<i8')]"
++        if sys.byteorder == 'little':
++            assert str(row.dtype) == "[('a', '<i8'), ('b', '<i8')]"
++        else:
++            assert str(row.dtype) == "[('a', '>i8'), ('b', '>i8')]"
+ 
+     def test_ref(self):
+         """Row is a reference into original table data"""
diff --git a/debian/patches/series b/debian/patches/series
index 9385d86..ab3e45b 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
-disable_mmap.patch
+fix_bigendian_ftbs.patch
+

-- 
Core functionality for performing astronomy and astrophysics with Python



More information about the debian-science-commits mailing list