--- lib/pyfits/tests/test_division.py +++ lib/pyfits/tests/test_division.py @@ -1,7 +1,10 @@ from __future__ import division # confidence high from __future__ import with_statement -from cStringIO import StringIO +try: + from cStringIO import StringIO +except: + from io import StringIO import numpy as np --- lib/pyfits/tests/test_structured.py +++ lib/pyfits/tests/test_structured.py @@ -65,8 +65,8 @@ st['f1'] = [1, 3, 5] st['f2'] = ['hello', 'world', 'byebye'] st['f3'] = np.random.random(st['f3'].shape) - print st.dtype.descr - print st + print(st.dtype.descr) + print(st) return st @@ -75,26 +75,26 @@ def test_structured(self): fname = self.data('stddata.fits') - print 'Reading from ', fname + print('Reading from ', fname) data1, h1 = pyfits.getdata(fname, ext=1, header=True) data2, h2 = pyfits.getdata(fname, ext=2, header=True) st = get_test_data() outfile = self.temp('test.fits') - print 'Writing to file data1:', outfile + print('Writing to file data1:', outfile) pyfits.writeto(outfile, data1, clobber=True) - print 'Appending to file: data2', outfile + print('Appending to file: data2', outfile) pyfits.append(outfile, data2) - print 'Appending to file: st', outfile + print('Appending to file: st', outfile) pyfits.append(outfile, st) - print st.dtype.descr - print st + print(st.dtype.descr) + print(st) assert st.dtype.isnative assert np.all(st['f1'] == [1,3,5]) - print 'Reading data back' + print('Reading data back') data1check, h1check = pyfits.getdata(outfile, ext=1, header=True) data2check, h2check = pyfits.getdata(outfile, ext=2, header=True) stcheck, sthcheck = pyfits.getdata(outfile, ext=3, header=True) @@ -103,12 +103,12 @@ raise ValueError('Fail') if not compare_arrays(data2, data2check, verbose=True): raise ValueError('Fail') - print st, stcheck + print(st, stcheck) if not compare_arrays(st, stcheck, verbose=True): raise ValueError('Fail') # try reading with view - print 'Reading with ndarray view' + print('Reading with ndarray view') dataviewcheck, hviewcheck = pyfits.getdata(outfile, ext=2, header=True, view=np.ndarray) if not compare_arrays(data2, dataviewcheck, verbose=True): --- lib/pyfits/tests/test_table.py +++ lib/pyfits/tests/test_table.py @@ -51,7 +51,7 @@ nfieldsa = len(a.dtype.names) nfieldsb = len(b.dtype.names) if nfieldsa != nfieldsb: - print "number of fields don't match" + print("number of fields don't match") return False for i in range(nfieldsa): fielda = a.field(i) @@ -63,21 +63,21 @@ if (type(fielda) != type(fieldb) and not (issubclass(type(fielda), type(fieldb)) or issubclass(type(fieldb), type(fielda)))): - print "type(fielda): ",type(fielda)," fielda: ",fielda - print "type(fieldb): ",type(fieldb)," fieldb: ",fieldb - print 'field %d type differs' % i + print("type(fielda): ",type(fielda)," fielda: ",fielda) + print("type(fieldb): ",type(fieldb)," fieldb: ",fieldb) + print('field %d type differs' % i) return False if isinstance(fielda[0], np.floating): if not comparefloats(fielda, fieldb): - print "fielda: ",fielda - print "fieldb: ",fieldb - print 'field %d differs' % i + print("fielda: ",fielda) + print("fieldb: ",fieldb) + print('field %d differs' % i) return False else: if np.any(fielda != fieldb): - print "fielda: ",fielda - print "fieldb: ",fieldb - print 'field %d differs' % i + print("fielda: ",fielda) + print("fieldb: ",fieldb) + print('field %d differs' % i) return False return True