Skip to content

gh-154942: Refresh statistics.kde cache after same-length data changes - #155034

Open
Taeknology wants to merge 1 commit into
python:mainfrom
Taeknology:fix/gh-154942-kde-cache
Open

gh-154942: Refresh statistics.kde cache after same-length data changes#155034
Taeknology wants to merge 1 commit into
python:mainfrom
Taeknology:fix/gh-154942-kde-cache

Conversation

@Taeknology

@Taeknology Taeknology commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #154942.

statistics.kde() now detects changes to the contents of mutable data sequences for bounded-support kernels. Previously, its sorted sample cache was refreshed only when the sequence length changed, so replacing a value without changing the length could produce a stale estimate.

The bounded-support path now compares the current data with a tuple snapshot and rebuilds the sorted sample only when the contents change. This preserves online updates while keeping bounded- and unbounded-support kernels consistent.

The statistics test suite passes, including new regression coverage for PDF and CDF estimates after a same-length value replacement.

@picnixz

picnixz commented Aug 2, 2026

Copy link
Copy Markdown
Member

I believe this could impede performance as we trcompute tuple(data). I also think it only assumes augmenting data updates and not altering data in place (what do the docs say?) and thus I would rather clarify the docs than changing the implementation. From a user perspective I find it already weird that updates are supported but from a semantic perspective it does not make sense to support destructive updates (only additive ones are relevant IMO)

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not convinced by the fact that it is a bug. I also think this PR is premature. In the future please avoid creating PRs until the issue has been acknowledged by a triager/core dev (unless it is clearly a bug)

@bedevere-app

bedevere-app Bot commented Aug 2, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

statistics.kde has inconsistent and counterintuitive caching behaviour

2 participants