Skip to content

r.resamp.stats: Fix quantile option being truncated to an integer - #7791

Merged
petrasovaa merged 1 commit into
OSGeo:mainfrom
HUN-sp:fix-resamp-stats-quantile
Aug 3, 2026
Merged

petrasovaa merged 1 commit into
OSGeo:mainfrom
HUN-sp:fix-resamp-stats-quantile

Conversation

@HUN-sp

@HUN-sp HUN-sp commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

quantile is stored as a double, but its value was parsed using atoi(), causing any value less than 1.0 to be truncated to 0. As a result, c_quant() always received 0 as the requested quantile, returning the minimum value. This meant that method=quantile effectively behaved as method=minimum, and the quantile option had no effect.

Verification

Verified on the nc_spm_08_grass7 dataset with res=100:

Comparison | Difference -- | -- quantile=0.5 vs. minimum | 0 ... 0 (identical) quantile=0.9 vs. minimum | 0 ... 0 (identical) quantile=0.5 vs. median | -21.67 ... 0 (expected to be 0)

Fix

Replace atoi() with atof() so fractional quantile values are parsed correctly.

This matches the implementation used by other GRASS modules exposing the same option, including:

  • r.neighbors

  • r.series

  • r3.neighbors

Notes

Found while reviewing #7044 and submitted as a separate PR, as requested, to keep the fix independent.

The quantile variable is a double, but its value was parsed with atoi, so
any quantile below 1.0 became 0 and method=quantile returned the minimum
regardless of the requested quantile. Use atof, as r.neighbors, r.series
and r3.neighbors already do for the same option.
@github-actions github-actions Bot added raster Related to raster data processing C Related code is in C module labels Jul 31, 2026

@petrasovaa petrasovaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix is fine, but please don't leave AI response in the PR description, it is very annoying.

@petrasovaa
petrasovaa merged commit 28e3842 into OSGeo:main Aug 3, 2026
26 checks passed
@HUN-sp

HUN-sp commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@petrasovaa Just being honest here , I thought the fix is what matters and pr description should just describe what the fix is . If it's formatted through AI , it shouldn't be the problem I guess . Well I will keep that in mind whenever I will raise another PR.

@petrasovaa

Copy link
Copy Markdown
Contributor

See the first sentence of the PR description, please just be more careful what you paste.

@github-actions github-actions Bot added this to the 8.6.0 milestone Aug 3, 2026
@HUN-sp

HUN-sp commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Okay I will edit , I understand it was in hurry bury

@HUN-sp

HUN-sp commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@petrasovaa what about PR #7044 ? Can u review it please ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Related code is in C module raster Related to raster data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants