Skip to content

Commit

Permalink
Tighten some asserts in test_warpExposure.py
Browse files Browse the repository at this point in the history
Catch lsst.pex.exceptions.InvalidParameterError instead of
Exception (in some cases) or lsst.pex.exceptions.Exception
(in others)
  • Loading branch information
r-owen committed May 10, 2018
1 parent 636868a commit f8304a7
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions tests/test_warpExposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,12 @@ def testNullWcs(self, interpLength=10):
exposureWithoutWcs = afwImage.ExposureF(mi.getDimensions())
warpingControl = afwMath.WarpingControl(
"bilinear", "", 0, interpLength)
try:
afwMath.warpExposure(
exposureWithWcs, exposureWithoutWcs, warpingControl)
self.fail("warping from a source Exception with no Wcs should fail")
except Exception:
pass
try:
afwMath.warpExposure(exposureWithoutWcs,
exposureWithWcs, warpingControl)
self.fail(
"warping into a destination Exception with no Wcs should fail")
except Exception:
pass

with self.assertRaises(pexExcept.InvalidParameterError):
afwMath.warpExposure(exposureWithWcs, exposureWithoutWcs, warpingControl)

with self.assertRaises(pexExcept.InvalidParameterError):
afwMath.warpExposure(exposureWithoutWcs, exposureWithWcs, warpingControl)

def testWarpIntoSelf(self, interpLength=10):
"""Cannot warp in-place
Expand All @@ -218,8 +211,7 @@ def testWarpIntoSelf(self, interpLength=10):
afwMath.warpImage(maskedImage, wcs, maskedImage, wcs, warpingControl)

with self.assertRaises(pexExcept.InvalidParameterError):
afwMath.warpImage(maskedImage.getImage(), wcs,
maskedImage.getImage(), wcs, warpingControl)
afwMath.warpImage(maskedImage.getImage(), wcs, maskedImage.getImage(), wcs, warpingControl)

def testWarpingControl(self):
"""Test the basic mechanics of WarpingControl
Expand Down Expand Up @@ -256,19 +248,19 @@ def testWarpingControlError(self):
("bilinear", "lanczos4"),
("lanczos3", "lanczos4"),
):
with self.assertRaises(pexExcept.Exception):
with self.assertRaises(pexExcept.InvalidParameterError):
afwMath.WarpingControl(kernelName, maskKernelName)

# error: new mask kernel larger than main kernel
warpingControl = afwMath.WarpingControl("bilinear")
for maskKernelName in ("lanczos3", "lanczos4"):
with self.assertRaises(pexExcept.Exception):
with self.assertRaises(pexExcept.InvalidParameterError):
warpingControl.setMaskWarpingKernelName(maskKernelName)

# error: new kernel smaller than mask kernel
warpingControl = afwMath.WarpingControl("lanczos4", "lanczos4")
for kernelName in ("bilinear", "lanczos3"):
with self.assertRaises(pexExcept.Exception):
with self.assertRaises(pexExcept.InvalidParameterError):
warpingControl.setWarpingKernelName(kernelName)

# OK: main kernel at least as big as mask kernel
Expand All @@ -288,7 +280,7 @@ def testWarpingControlError(self):
("lanczos3", "badname"),
("lanczos3", "lanczos"),
):
with self.assertRaises(pexExcept.Exception):
with self.assertRaises(pexExcept.InvalidParameterError):
afwMath.WarpingControl(kernelName, maskKernelName)

def testWarpMask(self):
Expand Down

0 comments on commit f8304a7

Please sign in to comment.