-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-7233: Pytest updates #18
Changes from all commits
6ede5ac
9ba4856
5e5d68a
c957d20
022619a
7dc9ec4
1356ddf
edd0d5a
bb1a21d
779e13a
0065eff
fb16164
a389d9a
af40257
8986b94
f824356
d51dcb6
a0322f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ doc/*.inc | |
doc/doxygen.conf | ||
doc/xml | ||
tests/.tests | ||
tests/.cache | ||
version.py |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,21 +22,22 @@ | |
# see <http://www.lsstcorp.org/LegalNotices/>. | ||
# | ||
import unittest | ||
import numpy as np | ||
|
||
import lsst.utils.tests as tests | ||
import lsst.utils.tests | ||
import lsst.afw.image as afwImage | ||
import lsst.meas.algorithms as measAlg | ||
import lsst.afw.geom as afwGeom | ||
import lsst.afw.display.ds9 as ds9 | ||
import lsst.afw.display.utils as displayUtils | ||
import lsst.ip.isr as ipIsr | ||
|
||
try: | ||
type(display) | ||
except NameError: | ||
display = False | ||
# set to True to display images in ds9 | ||
display = False | ||
|
||
|
||
class DefectTestCases(lsst.utils.tests.TestCase): | ||
|
||
class DefectTestCases(unittest.TestCase): | ||
def setUp(self): | ||
self.setVal = 10. | ||
|
||
|
@@ -47,16 +48,16 @@ def testDefectBase(self): | |
"""Test DefectBases""" | ||
|
||
defectList = measAlg.DefectListT() | ||
ccdImage = afwImage.MaskedImageF(250,225) | ||
ccdImage = afwImage.MaskedImageF(250, 225) | ||
ccdImage.set(self.setVal, 0, self.setVal) | ||
# | ||
# Insert some defects into the Ccd | ||
# | ||
for x0, y0, x1, y1 in [ | ||
(34, 0, 35, 80 ), | ||
(34, 81, 34, 100), | ||
(34, 0, 35, 80), | ||
(34, 81, 34, 100), | ||
(180, 100, 182, 130), | ||
]: | ||
]: | ||
bbox = afwGeom.Box2I(afwGeom.Point2I(x0, y0), afwGeom.Point2I(x1, y1)) | ||
defectList.append(measAlg.Defect(bbox)) | ||
bad = ccdImage.Factory(ccdImage, bbox, afwImage.LOCAL) | ||
|
@@ -67,7 +68,7 @@ def testDefectBase(self): | |
bitMask = mask.getPlaneBitMask('BAD') | ||
for d in defectList: | ||
bad = mask.Factory(mask, d.getBBox(), afwImage.LOCAL) | ||
self.assertTrue((bad.getArray()&bitMask == bitMask).all()) | ||
self.assertTrue((bad.getArray() & bitMask == bitMask).all()) | ||
|
||
if display: | ||
ds9.mtv(ccdImage.getImage(), title="Defects") | ||
|
@@ -79,7 +80,9 @@ def testDefectBase(self): | |
im = ccdImage.getImage() | ||
for d in defectList: | ||
intrp = im.Factory(im, d.getBBox()) | ||
self.assertTrue((intrp.getArray() == self.setVal).all()) | ||
expect = np.empty_like(intrp.getArray()) | ||
expect[:] = self.setVal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it matters: I'm refilling it with self.setVal. I guess I'd rather just start with an uninitialized array, to ensure it doesn't accidentally use the values it wants to compare against. |
||
self.assertImagesEqual(intrp, expect) | ||
|
||
if display: | ||
ds9.mtv(ccdImage.getImage(), title="Defects Interpolated") | ||
|
@@ -114,18 +117,14 @@ def testDefectsFromMaskedImage(self): | |
self.assertEqual(len(defectList), 2) | ||
|
||
|
||
def suite(): | ||
"""Returns a suite containing all the test cases in this module.""" | ||
tests.init() | ||
class MemoryTester(lsst.utils.tests.MemoryTestCase): | ||
pass | ||
|
||
|
||
suites = [] | ||
suites += unittest.makeSuite(DefectTestCases) | ||
suites += unittest.makeSuite(tests.MemoryTestCase) | ||
return unittest.TestSuite(suites) | ||
def setup_module(module): | ||
lsst.utils.tests.init() | ||
|
||
def run(exit=False): | ||
"""Run the tests""" | ||
tests.run(suite(), exit) | ||
|
||
if __name__ == "__main__": | ||
run(True) | ||
lsst.utils.tests.init() | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I like either solution. I assume the former was to allow this to be imported and pick up
display
if it existed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, but it's pretty strange. We don't have a good unified way to set a "display things in tests" variable. lsstDebug is kind of like that, but there are some tickets to rethink that system.