Skip to content

Commit

Permalink
Close Pool after using to avoid keeping open files, speed up installa…
Browse files Browse the repository at this point in the history
…tion of dependencies, and fix tests
  • Loading branch information
astrofrog committed May 7, 2015
1 parent 4f8d4d1 commit 28a265d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions reproject/spherical_intersect/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions reproject/spherical_intersect/tests/test_reproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

0 comments on commit 28a265d

Please sign in to comment.