Skip to content

Update kdtree and fix KDE radius - #444

Open
day01 wants to merge 2 commits into
statrs-dev:mainfrom
day01:feat/kdtree-0-8
Open

Update kdtree and fix KDE radius#444
day01 wants to merge 2 commits into
statrs-dev:mainfrom
day01:feat/kdtree-0-8

Conversation

@day01

@day01 day01 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Motivation

kdtree 0.8.1 intentionally changed within() to return unordered results in mrhooray/kdtree-rs#85. The existing KDE and KNN implementations used the last result as the neighborhood radius, which produces incorrect densities after the dependency update.

Changes

  • update kdtree from 0.7.0 to 0.8.1
  • compute the neighborhood radius from the farthest returned distance instead of relying on result order
  • add a regression test with deliberately unordered distances
  • update the MSRV lockfile

Refs:
#428

Summary by CodeRabbit

  • Bug Fixes

    • Improved density estimates by consistently calculating neighborhood radius from the farthest neighboring sample.
    • Added handling for empty neighbor-distance data.
  • Maintenance

    • Updated the optional spatial-indexing dependency and lockfile entries.
  • Tests

    • Added coverage for neighborhood radius calculation and farthest-distance selection.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.39%. Comparing base (10cf6d6) to head (b3d3db5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #444      +/-   ##
==========================================
+ Coverage   95.07%   95.39%   +0.31%     
==========================================
  Files          62       65       +3     
  Lines       14203    15069     +866     
==========================================
+ Hits        13504    14375     +871     
+ Misses        699      694       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@day01
day01 marked this pull request as ready for review August 12, 2026 08:29
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d67dfe5e-aa55-499c-afbc-54209762b708

📥 Commits

Reviewing files that changed from the base of the PR and between 92819b6 and edff6a8.

📒 Files selected for processing (5)
  • Cargo.lock.MSRV
  • Cargo.toml
  • src/density/kde.rs
  • src/density/knn.rs
  • src/density/mod.rs

Included review availability: Your plan includes up to 3 reviews per rolling hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The optional kdtree dependency is updated to 0.8.1. Density calculations now share a helper that selects the farthest neighbor distance and converts it to a kernel radius. A test covers the helper behavior.

Changes

Density radius and dependency updates

Layer / File(s) Summary
Update kdtree dependency resolution
Cargo.toml, Cargo.lock.MSRV
The optional kdtree dependency moves from 0.7.0 to 0.8.1. The lockfile updates related checksums and removes unused thiserror 1.x entries.
Centralize neighborhood radius calculation
src/density/mod.rs, src/density/kde.rs, src/density/knn.rs
neighborhood_radius selects the maximum neighbor distance and returns its square root. KDE and KNN use the helper for radius calculation. A test verifies farthest-distance selection.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to edff6

The dependency and KDE radius changes present no actionable merge-blocking risk in the supplied evidence; the PR is merge-ready after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes both main changes: the kdtree update and the KDE radius fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

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.

1 participant