-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
r.kappa: Fix failures, garbage output, fallback to category values #2573
Conversation
Although original code lacks any explanation why NA should not be printed for the first raster category, I do suspect it stems from idea that the first cat is 0 and before proper NULL support 0 was "no data" value.
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.
GCC and CodeQL are not happy. Otherwise no idea without testing or tests, sorry.
Probably another candidate for JSON output, but that's out of scope for this PR.
There are more issues as some values are calculated incorrectly if input data is not sequential numbers starting at 0. Thus just a draft as more work is needed.
I was thinking of shell script style with "-g" flag, but going for JSON also is an option. In separate PR, of course, after this PR is merged as this PR will have to be backported. |
These tests should fail as C code fixes will be in upcoming commits.
pii, pi, pj and pii all are arrays with size of ncat thus when nstats < ncat it was causing out of bounds reads and writes. A resulting segfault was reported in: https://trac.osgeo.org/grass/ticket/3978 A test covering this error already was added in previous commit.
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.
The code changes make sense to me in light of the individual commit messages (please include these descriptions into the final commit message, you could add pieces of them as comments too).
I executed the tests locally with the original code and in the one case where it actually runs and gives results, I get the same values as the ones in the tests, so the outputs which are working were not broken.
Thank you for the extra effort with the correctness test! I was really just thinking some "current values" check to see the before and after difference (or no difference).
I only noticed sub-optimal use of split in Python in tests which would be nice to have before merge.
Selected r.kappa indentation update from OSGeo#2544 (needed for backport r.kappa fixes in OSGeo#2573)
…2573) * use raster category values in matrix output if labels are not present * print NAs also for the first category Although original code lacks any explanation why NA should not be printed for the first raster category, I do suspect it stems from idea that the first cat is 0 and before proper NULL support 0 was "no data" value. * r.kappa: fix incorrect memory access and improve edge case handling pii, pi, pj and pii all are arrays with size of ncat thus when nstats < ncat it was causing out of bounds reads and writes. A resulting segfault was reported in: https://trac.osgeo.org/grass/ticket/3978 * tests for most of functionality
…SGeo#2573) * use raster category values in matrix output if labels are not present * print NAs also for the first category Although original code lacks any explanation why NA should not be printed for the first raster category, I do suspect it stems from idea that the first cat is 0 and before proper NULL support 0 was "no data" value. * r.kappa: fix incorrect memory access and improve edge case handling pii, pi, pj and pii all are arrays with size of ncat thus when nstats < ncat it was causing out of bounds reads and writes. A resulting segfault was reported in: https://trac.osgeo.org/grass/ticket/3978 * tests for most of functionality
…SGeo#2573) * use raster category values in matrix output if labels are not present * print NAs also for the first category Although original code lacks any explanation why NA should not be printed for the first raster category, I do suspect it stems from idea that the first cat is 0 and before proper NULL support 0 was "no data" value. * r.kappa: fix incorrect memory access and improve edge case handling pii, pi, pj and pii all are arrays with size of ncat thus when nstats < ncat it was causing out of bounds reads and writes. A resulting segfault was reported in: https://trac.osgeo.org/grass/ticket/3978 * tests for most of functionality
…SGeo#2573) * use raster category values in matrix output if labels are not present * print NAs also for the first category Although original code lacks any explanation why NA should not be printed for the first raster category, I do suspect it stems from idea that the first cat is 0 and before proper NULL support 0 was "no data" value. * r.kappa: fix incorrect memory access and improve edge case handling pii, pi, pj and pii all are arrays with size of ncat thus when nstats < ncat it was causing out of bounds reads and writes. A resulting segfault was reported in: https://trac.osgeo.org/grass/ticket/3978 * tests for most of functionality
r.kappa has some strange design decisions and produces strange or outright wrong output if input data doesn't match its expectations.
This PR fixes: