-
-
Notifications
You must be signed in to change notification settings - Fork 350
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
i.gensigset: fix possible pole and divide by zero errors in regroup #4500
base: main
Are you sure you want to change the base?
Conversation
imagery/i.gensigset/subcluster.c
Outdated
if (subsum > 0) | ||
likelihood += log(subsum) + maxlike; | ||
|
||
if (subsum) { |
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.
Didn't combine both of these in the same conditional as subsum
being negative is not valid for log
, but valid while calculating Data
.
Using logarithm function call with zero argument will lead to a pole error, which occurs if the mathematical function has an exact infinite result. Check if the argument value is zero before passing that to the log function to avoid such errors. I also added check for negative numbers just to make sure the argument is in the right domain for the log function as well. There was also a possible divide by zero scenario when we were dividing the class data by subsum, which can be zero. Added a conditional check which avoids going to that stage. Signed-off-by: Mohan Yelugoti <[email protected]>
3f08d03
to
2b1b9e6
Compare
Documented each supression issue with comments to distinguish between false positives and true positives awaiting resolution. For the false positives supressions, appropriate information is provided on why those were considered as false positive. True positives will be removed from the suppression file once their corresponding fixes(OSGeo#4702, OSGeo#4638, OSGeo#4500, OSGeo#4499) are merged. Run: `cppcheck --suppressions-list=.cppcheck-supressions <path>` Signed-off-by: Mohan Yelugoti <[email protected]>
Documented each suppression issue with comments to distinguish between false positives and true positives awaiting resolution. For the false positives suppressions, appropriate information is provided on why those were considered as false positive. True positives will be removed from the suppression file once their corresponding fixes(OSGeo#4702, OSGeo#4638, OSGeo#4500, OSGeo#4499) are merged. Run: `cppcheck --suppressions-list=.cppcheck-suppressions <path>` Signed-off-by: Mohan Yelugoti <[email protected]>
Maybe a fresh, updated CI run might be wanted before a merge, last run is getting old |
Can someone verify if returning 0 in these cases makes sense domain-specific-wize? For example, does it break usages to have 0 when unexpected without indications? Could we still rely on the results? Programming-wize, and math-wize, this looks fine |
Using logarithm function call with zero argument will lead to a pole error, which occurs if the mathematical function has an exact infinite result.
Check if the argument value is zero before passing that to the log function to avoid such errors. I also added check for negative numbers just to make sure the argument is in the right domain for the log function as well.
There was also a possible divide by zero scenario when we were dividing the class data by subsum, which can be zero. Added a conditional check which avoids going to that stage.