Package: astropy / 3.1.2-2

Fix-problem-with-tables-on-big-endian-archs.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From: Tim Plummer <Timothy.Plummer@lasp.colorado.edu>
Date: Tue, 26 Feb 2019 13:24:38 -0700
Subject: Fix problem with tables on big endian archs

https://github.com/astropy/astropy/issues/8458

[add11d1a5] Added changelog entries (+1 squashed commit)

[71d5051a3] Modified test TestColumnFunctions.test_coldefs_init_from_array for
coverage of datatypes of little and big endianess Fixed bug in
ColDefs._init_from_array to cover all possible unsigned numpy datatypes
---
 astropy/io/fits/column.py           | 13 +++++++------
 astropy/io/fits/tests/test_table.py |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/astropy/io/fits/column.py b/astropy/io/fits/column.py
index 0434f0b..b8d0c63 100644
--- a/astropy/io/fits/column.py
+++ b/astropy/io/fits/column.py
@@ -1423,12 +1423,13 @@ class ColDefs(NotifierMixin):
 
             # Check for unsigned ints.
             bzero = None
-            if 'I' in format and ftype.base == np.dtype('uint16'):
-                bzero = np.uint16(2**15)
-            elif 'J' in format and ftype.base == np.dtype('uint32'):
-                bzero = np.uint32(2**31)
-            elif 'K' in format and ftype.base == np.dtype('uint64'):
-                bzero = np.uint64(2**63)
+            if ftype.base.kind == 'u':
+                if 'I' in format:
+                    bzero = np.uint16(2**15)
+                elif 'J' in format:
+                    bzero = np.uint32(2**31)
+                elif 'K' in format:
+                    bzero = np.uint64(2**63)
 
             c = Column(name=cname, format=format,
                        array=array.view(np.ndarray)[cname], bzero=bzero,
diff --git a/astropy/io/fits/tests/test_table.py b/astropy/io/fits/tests/test_table.py
index decf2cd..8b25f1e 100644
--- a/astropy/io/fits/tests/test_table.py
+++ b/astropy/io/fits/tests/test_table.py
@@ -2930,7 +2930,7 @@ class TestColumnFunctions(FitsTestCase):
         """Test that ColDefs._init_from_array works with single element data-
         types as well as multi-element data-types
         """
-        nd_array = np.ndarray((1,), dtype=[('A', '<u4', (2,)), ('B', 'uint16')])
+        nd_array = np.ndarray((1,), dtype=[('A', '<u4', (2,)), ('B', '>u2')])
         col_defs = fits.column.ColDefs(nd_array)
         assert 2**31 == col_defs['A'].bzero
         assert 2**15 == col_defs['B'].bzero