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

Review for DM-5427: Handle empty variance array gracefuly. #34

Merged
merged 1 commit into from May 17, 2016

Conversation

jdswinbank
Copy link
Contributor

No description provided.

@jdswinbank
Copy link
Contributor Author

Typos in commit message: "gracefuly", "pixedls".

measRecord.set(self.varValue, medVar)
else:
measRecord.set(self.varValue, numpy.NaN)
raise bl.MeasurementError("Footprint empty, or all pixels are masked, can't compute median", bl.FlagHandler.FAILURE)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be appropriate to define a specific flag for this failure mode?

Is the reference to bl.FlagHandler.FAILURE appropriate? In some sense, I guess it is, but I think if we were doing it properly we'd actually have to define FAILURE_BAD_CENTROID above as bl.FlagHandler.FAILURE+1 rather than just assuming it's 1; if we can assume it's 1, then maybe we can just assume this is 0. Maybe a specific reference to FlagHandler.FAILURE is helpful to the reader? (On the other hand, I just wasted 5 minutes wondering about it...)

@jdswinbank
Copy link
Contributor Author

In addition to the minor comments on the code itself, please add an appropriate unit test.

@AstroVPK AstroVPK force-pushed the tickets/DM-5427 branch 4 times, most recently from 75222ef to 1362528 Compare May 16, 2016 21:14
#has all masked pixels at this point.
self.assertTrue(np.isnan(source.get("base_Variance_value")))
self.assertTrue(source.get("base_Variance_flag_emptyFootprint"))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it were possible, it would be nice to make this a separate test method -- it gives us more granularity when detecting failures. You could put all the logic which sets up and runs the test in common function and then have two tests which call it.

SingleFrameVariancePlugin attempts to compute the median of the
variance array for pixels in the heavy footprint of a source. Some
pixels are ignored because mask flags are set indicating that the pixel
is not to be trusted. Sometimes, this results in all pixels getting
rejected at which point numpy raises a RuntimeWarning stating that it
is trying to compute the median of an empty array. We check for the
empty array and raise a MeasurementError if all the pixels are flagged.
The testVariance unittest has been modified to test the new behavior.
@AstroVPK AstroVPK merged commit daa3b4d into master May 17, 2016
@ktlim ktlim deleted the tickets/DM-5427 branch August 25, 2018 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants