Skip to content

fix: Base cumulative functions return all NA after the first NA#326

Merged
etiennebacher merged 2 commits intoetiennebacher:mainfrom
Yousa-Mirage:Yousa-Mirage/issue325
Feb 16, 2026
Merged

fix: Base cumulative functions return all NA after the first NA#326
etiennebacher merged 2 commits intoetiennebacher:mainfrom
Yousa-Mirage:Yousa-Mirage/issue325

Conversation

@Yousa-Mirage
Copy link
Copy Markdown
Contributor

Fixes #325

I modified the pl_cum_*() functions, which use a boolean mask to make Polars and baseR behave consistently:

has_seen_na <- x$is_null()$cum_max()
pl$when(has_seen_na)$then(pl$lit(NA))$otherwise(x$cum_*())

This does not significantly increase computational complexity, nor does it break the LazyFrame. All tests passed.

Additionally, I added a test for the mathematical functions with NA in tests/testthat/test-funs_math.R.

@etiennebacher
Copy link
Copy Markdown
Owner

Thanks, can you update NEWS?

@Yousa-Mirage
Copy link
Copy Markdown
Contributor Author

Oh, I forgot to update the NEWS.md. I'm enjoying the Chinese New Year today 🎇. Can you please update it? Thank you and wish you Happy Lunar New Year ❤️!

@etiennebacher
Copy link
Copy Markdown
Owner

Sure, done! Enjoy the celebrations :)

@etiennebacher etiennebacher merged commit 11cf0f1 into etiennebacher:main Feb 16, 2026
9 checks passed
@Yousa-Mirage Yousa-Mirage deleted the Yousa-Mirage/issue325 branch February 16, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Base cumulative functions return all NA after the first NA

2 participants