From 28a265d6372b85a9d1eee1b62ab9edc1979d1e06 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Thu, 7 May 2015 14:51:30 +0200 Subject: [PATCH] Close Pool after using to avoid keeping open files, speed up installation of dependencies, and fix tests --- .travis.yml | 4 +++- reproject/spherical_intersect/core.py | 2 ++ reproject/spherical_intersect/tests/test_reproject.py | 8 ++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8ec9edec2..d5e0171ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -100,6 +100,7 @@ install: # conda for packages available through conda, or pip for any other # packages. You should leave the `numpy=$NUMPY_VERSION` in the `conda` # install since this ensures Numpy does not get automatically upgraded. + - if [[ $OPTIONAL_DEPS == true ]]; then $CONDA_INSTALL numpy=$NUMPY_VERSION matplotlib; fi - if [[ $OPTIONAL_DEPS == true ]]; then $PIP_INSTALL healpy; fi # DOCUMENTATION DEPENDENCIES @@ -109,7 +110,8 @@ install: - if [[ $SETUP_CMD == build_sphinx* ]]; then $CONDA_INSTALL numpy=$NUMPY_VERSION Sphinx=1.2 pyqt matplotlib; fi # COVERAGE DEPENDENCIES - - if [[ $SETUP_CMD == 'test --coverage' ]]; then $PIP_INSTALL coverage coveralls; fi + - if [[ $SETUP_CMD == 'test --coverage' ]]; then $CONDA_INSTALL coverage pyyaml requests; fi + - if [[ $SETUP_CMD == 'test --coverage' ]]; then $PIP_INSTALL coveralls; fi script: - python setup.py $SETUP_CMD diff --git a/reproject/spherical_intersect/core.py b/reproject/spherical_intersect/core.py index d17f8f967..5f4f9e957 100644 --- a/reproject/spherical_intersect/core.py +++ b/reproject/spherical_intersect/core.py @@ -169,6 +169,8 @@ def _reproject_celestial(array, wcs_in, wcs_out, shape_out, parallel=True, _lega results = pool.map(_reproject_slice, inputs) + pool.close() + array_new, weights = zip(*results) array_new = sum(array_new) diff --git a/reproject/spherical_intersect/tests/test_reproject.py b/reproject/spherical_intersect/tests/test_reproject.py index 68a01edfa..811656fef 100644 --- a/reproject/spherical_intersect/tests/test_reproject.py +++ b/reproject/spherical_intersect/tests/test_reproject.py @@ -70,9 +70,9 @@ def test_reproject_celestial_consistency(): wcs_in = WCS(fits.Header.fromstring(INPUT_HDR, sep='\n')) wcs_out = WCS(fits.Header.fromstring(OUTPUT_HDR, sep='\n')) - array1, footprint1 = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), _method='legacy') - array2, footprint2 = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), _method='c', parallel=False) - array3, footprint3 = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), _method='c', parallel=True) + array1, footprint1 = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), _legacy=True) + array2, footprint2 = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), parallel=False) + array3, footprint3 = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), parallel=True) np.testing.assert_allclose(array1, array2, rtol=1.e-6) np.testing.assert_allclose(array1, array3, rtol=1.e-6) @@ -88,7 +88,7 @@ def test_reproject_celestial_(): wcs_in = WCS(fits.Header.fromstring(INPUT_HDR, sep='\n')) wcs_out = WCS(fits.Header.fromstring(OUTPUT_HDR, sep='\n')) - array, footprint = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), _method='c', parallel=False) + array, footprint = _reproject_celestial(DATA, wcs_in, wcs_out, (4, 4), parallel=False) # TODO: improve agreement with Montage - at the moment agreement is ~10% np.testing.assert_allclose(array, MONTAGE_REF, rtol=0.09)