gh-154942: Refresh statistics.kde cache after same-length data changes - #155034
gh-154942: Refresh statistics.kde cache after same-length data changes#155034Taeknology wants to merge 1 commit into
Conversation
|
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) |
|
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 |
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.