Skip to content

Comments

r.univar: Use Kahan sum to avoid floating point errors#5750

Merged
echoix merged 26 commits intoOSGeo:mainfrom
cyliang368:runivar_thread_test
May 24, 2025
Merged

r.univar: Use Kahan sum to avoid floating point errors#5750
echoix merged 26 commits intoOSGeo:mainfrom
cyliang368:runivar_thread_test

Conversation

@cyliang368
Copy link
Contributor

@cyliang368 cyliang368 commented May 23, 2025

Univar sums values across large amounts of numbers, so the floating point errors could be huge if a naive sum is applied.

This PR introduces Kahan sum to solve this problem in r.univar. The testing reference numbers derived from the previous r.univar implementation are also updated.

@cyliang368 cyliang368 closed this May 23, 2025
@github-actions github-actions bot added raster Related to raster data processing Python Related code is in Python C Related code is in C module tests Related to Test Suite labels May 23, 2025
@cyliang368 cyliang368 reopened this May 23, 2025
@marisn marisn requested a review from nilason May 23, 2025 15:42
Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

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

Following files fails on Mac CI:

  • raster/r.mfilter/testsuite/test_r_mfilter.py
  • raster/r.resamp.filter/testsuite/test_r_resamp_filter.py
  • raster/r.resamp.interp/testsuite/test_r_resamp_interp.py

marisn
marisn previously approved these changes May 23, 2025
@marisn marisn added this to the 8.5.0 milestone May 23, 2025
@cyliang368 cyliang368 changed the title r.univar: Use Khan Sum Algorithm to avoid floating point errors r.univar: Use Kahan Sum to avoid floating point errors May 24, 2025
@nilason nilason enabled auto-merge (squash) May 24, 2025 05:44
auto-merge was automatically disabled May 24, 2025 14:16

Head branch was pushed to by a user without write access

@cyliang368 cyliang368 changed the title r.univar: Use Kahan Sum to avoid floating point errors r.univar: Use Kahan sum to avoid floating point errors May 24, 2025
@echoix echoix merged commit c7928be into OSGeo:main May 24, 2025
25 checks passed
@cyliang368 cyliang368 deleted the runivar_thread_test branch July 26, 2025 18:24
@nilason nilason added the backport to 8.4 PR needs to be backported to release branch 8.4 label Nov 18, 2025
@nilason
Copy link
Contributor

nilason commented Nov 18, 2025

Tagging this for backport so we do not forget it. To be discussed...

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

Labels

backport to 8.4 PR needs to be backported to release branch 8.4 C Related code is in C libraries module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants