You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-python/montage-wrapper/files/montage-wrapper-0.9.8-fix_t...

41 lines
2.2 KiB

Author: Ole Streicher <olebole@debian.org>
Description: Make sure that opened FITS files are closed after the test
--- a/montage_wrapper/tests/test_wrappers.py
+++ b/montage_wrapper/tests/test_wrappers.py
@@ -46,21 +46,21 @@
def test_mosaic(self):
mosaic(os.path.join(self.tmpdir, 'raw'),os.path.join(self.tmpdir, 'mosaic'), hdu=0)
- hdu = fits.open(os.path.join(self.tmpdir, 'mosaic', 'mosaic.fits'))[0]
- assert hdu.data.shape == (288, 282)
- valid = hdu.data[~np.isnan(hdu.data)]
- assert len(valid) == 65029
- assert_allclose(np.std(valid), 0.12658458001333581, 1e-5)
- assert_allclose(np.mean(valid), 0.4995945318627074, 1e-5)
- assert_allclose(np.median(valid), 0.5003376603126526, 1e-5)
+ with fits.open(os.path.join(self.tmpdir, 'mosaic', 'mosaic.fits')) as hdu:
+ assert hdu[0].data.shape == (288, 282)
+ valid = hdu[0].data[~np.isnan(hdu[0].data)]
+ assert len(valid) == 65029
+ assert_allclose(np.std(valid), 0.12658458001333581, 1e-5)
+ assert_allclose(np.mean(valid), 0.4995945318627074, 1e-5)
+ assert_allclose(np.median(valid), 0.5003376603126526, 1e-5)
@pytest.mark.xfail() # results are not consistent on different machines
def test_mosaic_background_match(self):
mosaic(os.path.join(self.tmpdir, 'raw'),os.path.join(self.tmpdir, 'mosaic_bkgmatch'), background_match=True)
- hdu = fits.open(os.path.join(self.tmpdir, 'mosaic_bkgmatch', 'mosaic.fits'))[0]
- assert hdu.data.shape == (288, 282)
- valid = hdu.data[~np.isnan(hdu.data)]
- assert len(valid) == 65029
- assert_allclose(np.std(valid), 0.12661606622654725)
- assert_allclose(np.mean(valid), 0.4994805202294361)
- assert_allclose(np.median(valid), 0.5002447366714478)
+ with fits.open(os.path.join(self.tmpdir, 'mosaic_bkgmatch', 'mosaic.fits')) as hdu:
+ assert hdu[0].data.shape == (288, 282)
+ valid = hdu[0].data[~np.isnan(hdu[0].data)]
+ assert len(valid) == 65029
+ assert_allclose(np.std(valid), 0.12661606622654725)
+ assert_allclose(np.mean(valid), 0.4994805202294361)
+ assert_allclose(np.median(valid), 0.5002447366714478)