Skip to content

Instantly share code, notes, and snippets.

@astrofrog
Created August 14, 2014 11:27
Show Gist options
  • Select an option

  • Save astrofrog/00facc1267ff0e218475 to your computer and use it in GitHub Desktop.

Select an option

Save astrofrog/00facc1267ff0e218475 to your computer and use it in GitHub Desktop.
________________ TestUintFunctions.test_uint[u8-False] ____________________
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x00000000163AD780>
utype = 'u8', compressed = False
@pytest.mark.parametrize(('utype','compressed'),
[('u2', False), ('u4', False), ('u8', False), ('u2', True),
('u4',True)]) #,('u8',True)])
def test_uint(self, utype, compressed):
bits = 8*int(utype[1])
if platform.architecture()[0] == '64bit' or bits != 64:
if compressed:
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3]))
hdu_number = 1
else:
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3]))
hdu_number = 0
hdu.scale('int{0:d}'.format(bits), '', bzero=2 ** (bits-1))
with ignore_warnings():
hdu.writeto(self.temp('tempfile.fits'), clobber=True)
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul:
assert hdul[hdu_number].data.dtype == self.utype_map[utype]
> assert (hdul[hdu_number].data == np.array(
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1,
0, 1, 2, 3],
dtype=self.utype_map[utype])).all()
E assert <built-in method all of numpy.ndarray object at 0x0000000005FD0800>()
E + where <built-in method all of numpy.ndarray object at 0x0000000005FD0800> = array([9223372036854775805, 9223372036854775806, 9223372036854775807,\n 9...72036854775809, 9223372036854775810,\n 9223372036854775811], dtype=uint64) == array([18446744073709551613, 18446744073709551614, 18446744073709551615,\n ... 1, 2,\n 3], dtype=uint64).all
E + where array([9223372036854775805, 9223372036854775806, 9223372036854775807,\n 9...72036854775809, 9223372036854775810,\n 9223372036854775811], dtype=uint64) = <astropy.io.fits.hdu.image.PrimaryHDU object at 0x00000000163AD048>.data
E + and array([18446744073709551613, 18446744073709551614, 18446744073709551615,\n ... 1, 2,\n 3], dtype=uint64) = <built-in function array>([18446744073709551613L, 18446744073709551614L, 18446744073709551615L, 0, 1, 2, ...], dtype=<type 'numpy.uint64'>)
E + where <built-in function array> = np.array
astropy\io\fits\tests\test_uint.py:43: AssertionError
_________________________ test_setitem_invalid_shape __________________________
def test_setitem_invalid_shape():
f = FlagCollection(shape=(1, 2, 3))
with pytest.raises(Exception) as exc:
f['a'] = np.ones((3, 2, 1))
> assert exc.value.args[0] == 'flags array shape (3, 2, 1) does not match data shape (1, 2, 3)'
E assert 'flags array ...ape (1, 2, 3)' == 'flags array s...ape (1, 2, 3)'
E - flags array shape (3L, 2L, 1L) does not match data shape (1, 2, 3)
E ? - - -
E + flags array shape (3, 2, 1) does not match data shape (1, 2, 3)
astropy\nddata\tests\test_flag_collection.py:49: AssertionError
_________________________ test_setitem_invalid_shape __________________________
def test_setitem_invalid_shape():
f = FlagCollection(shape=(1, 2, 3))
with pytest.raises(Exception) as exc:
f['a'] = np.ones((3, 2, 1))
> assert exc.value.args[0] == 'flags array shape (3, 2, 1) does not match data shape (1, 2, 3)'
E assert 'flags array ...ape (1, 2, 3)' == 'flags array s...ape (1, 2, 3)'
E - flags array shape (3L, 2L, 1L) does not match data shape (1, 2, 3)
E ? - - -
E + flags array shape (3, 2, 1) does not match data shape (1, 2, 3)
astropy\nddata\tests\test_flag_collection.py:49: AssertionError
_________________ [doctest] astropy.wcs.wcs.WCS.all_world2pix _________________
1948 ...
1949 NoConvergence: 'WCS.all_world2pix' failed to converge to the
1950 requested accuracy. After 3 iterations, the solution is
1951 diverging at least for one input point.
1952
1953 >>> # Now try to use some diverging data:
1954 >>> divradec = w.all_pix2world([[1.0, 1.0],
1955 ... [10000.0, 50000.0],
1956 ... [3.0, 1.0]], 1)
1957 >>> print(divradec)
Expected:
[ 0.99999996 0.99999997 0.99999997]
Got:
[ 0.99999997 0.99999997 0.99999997]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment