Skip to content
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-14580: Create tests for BestSeeingWcsSelectImagesTask #223

Merged
merged 2 commits into from Oct 23, 2018

Conversation

ebellm
Copy link
Contributor

@ebellm ebellm commented Oct 2, 2018

No description provided.

@ebellm ebellm requested a review from mrawls October 2, 2018 18:02
Copy link
Contributor

@mrawls mrawls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray tests! I have a suggestion for another test you can add to simulate a more realistic situation, but these are much better than no tests, and as a bonus it helped me see Mock in action.

@@ -400,7 +400,7 @@ def runDataRef(self, dataRef, coordList, makeDataRefList=True,
if selectDataList is None:
selectDataList = []

result = super().runDataRef(dataRef, coordList, makeDataRefList, selectDataList)
result = super().runDataRef(dataRef, coordList, makeDataRefList=True, selectDataList=selectDataList)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default makeDataRefList is True in both WcsSelectImagesTask and BestSeeingWcsSelectImagesTask, so it's not clear to me why you need to explicitly put it here also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to allow BestSeeingWcsSelectImagesTask to have makeDataRefList = False. But the BestSeeingWcsSelectImagesTask relies on having the dataRefList returned by the subclassed WcsImagesTask, so we have to set makeDataRefList = True in the call to super.

Parameters
----------
mockFWHMs : function, iterable, exeception, or `None`
Returns FWHM of mocked images
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this actually returns anything, so this should probably be, e.g., "Creates". If I'm wrong and it does return something, please use the proper Returns numpydoc syntax.

self.calexp = unittest.mock.Mock(spec=lsst.afw.image.ExposureD)
self.calexp.getPsf.return_value.computeShape.return_value.getDeterminantRadius.side_effect \
= mockDeterminantRadii()
self.dataId = "I'm a mock!"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my new favorite dataId 💯


self.selectList = [self.selectStruct] * len(self.mockFWHMs)

def testConfigNImagesGTZero(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know many of these are super self explanatory, but please add a short docstring to each anyway.

class BestSeeingWcsSelectImagesTest(lsst.utils.tests.TestCase):

def setUp(self):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous whitespace?

result = task.runDataRef(self.dataRef, self.coordList,
selectDataList=self.selectList, makeDataRefList=False)
self.assertIsNone(result.dataRefList)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These test cases are marginally interesting, but what I'd really like to see is a slightly more realistic case where more than Nmax images meet the good seeing criterion but have different seeings. For example, if there are 10 images with acceptable FWHM values, but they aren't all the same, and Nmax = 3, I think the desired behavior would be for the selector to choose the three with the lowest FWHM values. This requires testing more than just the length of the resulting exposure list, but rather what FWHM values and/or dataIds made it into the list.

result = task.runDataRef(self.dataRef, self.coordList, selectDataList=self.selectList)
self.assertEqual(len(result.exposureInfoList), 3)

def testSelectDefaultMakeDatarRefListIsFalse(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the name (your data is (are?) pirate flavored... Datarrrrrr...)

@ebellm ebellm force-pushed the tickets/DM-14580 branch 2 times, most recently from fbe46e9 to 8603310 Compare October 19, 2018 00:02
@ebellm ebellm merged commit 9b444f3 into master Oct 23, 2018
@ebellm ebellm deleted the tickets/DM-14580 branch October 23, 2018 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants