Gentoo Archives: gentoo-commits

From: "Kacper Kowalik (xarthisius)" <xarthisius@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-python/pyfits/files: pyfits-3.0.4-tests_python3.patch
Date: Fri, 06 Jan 2012 16:54:25
Message-Id: 20120106165411.74B392004B@flycatcher.gentoo.org
1 xarthisius 12/01/06 16:54:11
2
3 Added: pyfits-3.0.4-tests_python3.patch
4 Log:
5 Version bump with Python3 support. Claim for sci-astronomy
6
7 (Portage version: 2.2.0_alpha84/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 dev-python/pyfits/files/pyfits-3.0.4-tests_python3.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/pyfits/files/pyfits-3.0.4-tests_python3.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/pyfits/files/pyfits-3.0.4-tests_python3.patch?rev=1.1&content-type=text/plain
14
15 Index: pyfits-3.0.4-tests_python3.patch
16 ===================================================================
17 --- lib/pyfits/tests/test_division.py
18 +++ lib/pyfits/tests/test_division.py
19 @@ -1,7 +1,10 @@
20 from __future__ import division # confidence high
21 from __future__ import with_statement
22
23 -from cStringIO import StringIO
24 +try:
25 + from cStringIO import StringIO
26 +except:
27 + from io import StringIO
28
29 import numpy as np
30
31 --- lib/pyfits/tests/test_structured.py
32 +++ lib/pyfits/tests/test_structured.py
33 @@ -65,8 +65,8 @@
34 st['f1'] = [1, 3, 5]
35 st['f2'] = ['hello', 'world', 'byebye']
36 st['f3'] = np.random.random(st['f3'].shape)
37 - print st.dtype.descr
38 - print st
39 + print(st.dtype.descr)
40 + print(st)
41
42 return st
43
44 @@ -75,26 +75,26 @@
45 def test_structured(self):
46 fname = self.data('stddata.fits')
47
48 - print 'Reading from ', fname
49 + print('Reading from ', fname)
50 data1, h1 = pyfits.getdata(fname, ext=1, header=True)
51 data2, h2 = pyfits.getdata(fname, ext=2, header=True)
52
53 st = get_test_data()
54
55 outfile = self.temp('test.fits')
56 - print 'Writing to file data1:', outfile
57 + print('Writing to file data1:', outfile)
58 pyfits.writeto(outfile, data1, clobber=True)
59 - print 'Appending to file: data2', outfile
60 + print('Appending to file: data2', outfile)
61 pyfits.append(outfile, data2)
62
63 - print 'Appending to file: st', outfile
64 + print('Appending to file: st', outfile)
65 pyfits.append(outfile, st)
66 - print st.dtype.descr
67 - print st
68 + print(st.dtype.descr)
69 + print(st)
70 assert st.dtype.isnative
71 assert np.all(st['f1'] == [1,3,5])
72
73 - print 'Reading data back'
74 + print('Reading data back')
75 data1check, h1check = pyfits.getdata(outfile, ext=1, header=True)
76 data2check, h2check = pyfits.getdata(outfile, ext=2, header=True)
77 stcheck, sthcheck = pyfits.getdata(outfile, ext=3, header=True)
78 @@ -103,12 +103,12 @@
79 raise ValueError('Fail')
80 if not compare_arrays(data2, data2check, verbose=True):
81 raise ValueError('Fail')
82 - print st, stcheck
83 + print(st, stcheck)
84 if not compare_arrays(st, stcheck, verbose=True):
85 raise ValueError('Fail')
86
87 # try reading with view
88 - print 'Reading with ndarray view'
89 + print('Reading with ndarray view')
90 dataviewcheck, hviewcheck = pyfits.getdata(outfile, ext=2, header=True,
91 view=np.ndarray)
92 if not compare_arrays(data2, dataviewcheck, verbose=True):
93 --- lib/pyfits/tests/test_table.py
94 +++ lib/pyfits/tests/test_table.py
95 @@ -51,7 +51,7 @@
96 nfieldsa = len(a.dtype.names)
97 nfieldsb = len(b.dtype.names)
98 if nfieldsa != nfieldsb:
99 - print "number of fields don't match"
100 + print("number of fields don't match")
101 return False
102 for i in range(nfieldsa):
103 fielda = a.field(i)
104 @@ -63,21 +63,21 @@
105 if (type(fielda) != type(fieldb) and not
106 (issubclass(type(fielda), type(fieldb)) or
107 issubclass(type(fieldb), type(fielda)))):
108 - print "type(fielda): ",type(fielda)," fielda: ",fielda
109 - print "type(fieldb): ",type(fieldb)," fieldb: ",fieldb
110 - print 'field %d type differs' % i
111 + print("type(fielda): ",type(fielda)," fielda: ",fielda)
112 + print("type(fieldb): ",type(fieldb)," fieldb: ",fieldb)
113 + print('field %d type differs' % i)
114 return False
115 if isinstance(fielda[0], np.floating):
116 if not comparefloats(fielda, fieldb):
117 - print "fielda: ",fielda
118 - print "fieldb: ",fieldb
119 - print 'field %d differs' % i
120 + print("fielda: ",fielda)
121 + print("fieldb: ",fieldb)
122 + print('field %d differs' % i)
123 return False
124 else:
125 if np.any(fielda != fieldb):
126 - print "fielda: ",fielda
127 - print "fieldb: ",fieldb
128 - print 'field %d differs' % i
129 + print("fielda: ",fielda)
130 + print("fieldb: ",fieldb)
131 + print('field %d differs' % i)
132 return False
133 return True