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-30163: Replace asserts by exceptions, cleanup calcmom #208
Conversation
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.
Left a comment on Jira about how the exception should ideally be an InvalidParameterError and not a RuntimeError. Also, the commit message must start with a capitalized letter.
a9e0e93
to
1cf3ea0
Compare
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 can confirm that the code that used to crash is now exiting gracefully with a useful error message. The commit has to split up into a clean up commit and the one that prevents the crash. My earlier comment about the capitalization was for the commit message, not the PR title. See https://developer.lsst.io/work/flow.html#appendix-commit-message-best-practices
@@ -560,8 +574,9 @@ bool getAdaptiveMoments(ImageT const &mimage, double bkgd, double xcen, double y | |||
*/ | |||
if (shape->flags[SdssShapeAlgorithm::UNWEIGHTED.number]) { | |||
w11 = w22 = w12 = 0; | |||
if (calcmom<false>(image, xcen, ycen, bbox, bkgd, interpflag, w11, w12, w22, &I0, &sum, &sumx, &sumy, | |||
&sumxx, &sumxy, &sumyy, NULL, negative) < 0 || | |||
double ignored; |
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.
Curious why this is ignored
in place of sums4
.
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.
In the old code NULL was passed. One could rename it to sums4, but this is never used.
The old code used pointers to pass optional parameters C-style.
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.
Hmm, may be still keep the variable name to psums4
or sums4
but just add a comment saying it is ignored? It'll prevent looking up the definition in the future to see what that NULL corresponds to.
@@ -190,34 +190,23 @@ geom::Box2I computeAdaptiveMomentsBBox(geom::Box2I const &bbox, // full ima | |||
/* | |||
* Calculate weighted moments of an object up to 2nd order | |||
*/ | |||
template <bool instFluxOnly, typename ImageT> |
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.
Why is the option to compute instFluxOnly
removed? It may not be used regularly, but it seems like a perfectly good option to have.
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.
calcmon is overloaded now instFluxOnly instantiated two different versions of the functions with C style pointers.One could rename calcmon to make this explicit.
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.
Ah, yes. Makes sense. I'm happy as long as there's an option to calculate only the instFlux
.
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.
Yeah, the old code was C translated into bad C++.
1cf3ea0
to
ef7ca91
Compare
No description provided.