Skip to content

refactor(geometry): streamline iterator helpers for diagnostics work#471

Merged
acgetchell merged 2 commits into
mainfrom
refactor/353-iterator-diagnostics
Jun 19, 2026
Merged

refactor(geometry): streamline iterator helpers for diagnostics work#471
acgetchell merged 2 commits into
mainfrom
refactor/353-iterator-diagnostics

Conversation

@acgetchell

Copy link
Copy Markdown
Owner
  • Preserve point-generator preallocation while using fallible iterator control flow.
  • Extract Poisson spacing checks and stream geometry test distance calculations.
  • Gate benchmark setup tracing behind bench-logging and update diagnostics examples to use DelaunayResult.

Closes #353

- Preserve point-generator preallocation while using fallible iterator control flow.
- Extract Poisson spacing checks and stream geometry test distance calculations.
- Gate benchmark setup tracing behind bench-logging and update diagnostics examples to use DelaunayResult.
@acgetchell acgetchell self-assigned this Jun 19, 2026
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 67bc53ad-b2b6-4866-b08b-83683f32fc4b

📥 Commits

Reviewing files that changed from the base of the PR and between f4e1135 and 011fb00.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • .github/workflows/benchmarks.yml
  • .github/workflows/ci.yml
  • .github/workflows/codecov.yml
  • .github/workflows/generate-baseline.yml
  • .github/workflows/release-benchmarks.yml
  • .github/workflows/semgrep-sarif.yml
  • benches/common/bench_utils.rs
  • docs/dev/tooling-alignment.md
  • justfile
  • pyproject.toml
  • src/geometry/algorithms/convex_hull.rs
✅ Files skipped from review due to trivial changes (6)
  • .github/workflows/codecov.yml
  • .github/workflows/generate-baseline.yml
  • .github/workflows/semgrep-sarif.yml
  • pyproject.toml
  • justfile
  • .github/workflows/benchmarks.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • benches/common/bench_utils.rs
  • src/geometry/algorithms/convex_hull.rs

Walkthrough

Refactors collection-building loops to iterator pipelines (array::from_fn, try_fold, map/filter/collect) across geometry utilities, point generators, and tests. Fixes doc examples in builder, validation, and diagnostics. Feature-gates benchmark tracing imports and initialization behind the bench-logging Cargo feature. Updates tool versions across CI workflows and development configuration.

Changes

Iterator Refactoring, Doc Fixes, and Bench Feature Gating

Layer / File(s) Summary
Feature-gate bench tracing
benches/common/bench_utils.rs
Once/EnvFilter imports and the init_tracing body are compiled only when bench-logging is enabled; a no-op const fn is emitted otherwise. abort_benchmark conditionally emits tracing::error! or discards the message before calling process::exit(1).
Fix doc examples
docs/diagnostics.md, src/delaunay/builder.rs, src/delaunay/validation.rs
Builder examples add explicit .map_err(DelaunayTriangulationConstructionError::from)?; validation example replaces JSON round-trip with tds().clone(); diagnostics example changes report.is_valid() to report.is_ok().
Iterator refactoring in geometry utilities
src/geometry/quality.rs, src/geometry/util/point_generation.rs
scale_aware_epsilon replaces nested loops with array::from_fn + fold; generate_random_points_in_range_with_rng and generate_random_points_periodic switch to try_fold; new is_poisson_candidate_spaced helper encapsulates the Poisson spacing predicate.
Iterator refactoring in tests
src/geometry/algorithms/convex_hull.rs, tests/proptest_geometry.rs
Convex hull tests replace vec![]/loop accumulation with array literals and iterator pipelines (map/filter/count, collect). Proptest circumcenter equidistance test uses array::from_fn + hypot iterator chain instead of Vec + indexed loops.

Tool Version Updates

Layer / File(s) Summary
Update CI workflow tool versions
.github/workflows/benchmarks.yml, .github/workflows/ci.yml, .github/workflows/codecov.yml, .github/workflows/generate-baseline.yml, .github/workflows/release-benchmarks.yml, .github/workflows/semgrep-sarif.yml
Workflows bump uv from 0.11.20 to 0.11.22 and just from 1.52.0 to 1.53.0 across all benchmark and CI steps.
Update local tool and dependency versions
justfile, pyproject.toml, docs/dev/tooling-alignment.md
justfile pins just to 1.53.0 and rumdl to 0.2.20; pyproject.toml updates semgrep to 1.167.0; tooling documentation syncs all version pins.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • acgetchell/delaunay#468: Modifies the same benches/common/bench_utils.rs file with overlapping changes to abort_benchmark and the bench-logging feature gate.
  • acgetchell/delaunay#409: Both PRs update doc examples in src/delaunay/builder.rs to use explicit error mapping with .map_err(...)?. patterns for fallible constructors.
  • acgetchell/delaunay#362: Both PRs modify the same docs/diagnostics.md Validation Reports example, updating the API calls shown.

Suggested labels

documentation, enhancement, rust

🐇 A loop is just an iterator in disguise,
So I hopped through the code with my map and my eyes.
With from_fn and fold I replaced every push,
And try_fold did wonders — no need for a rush!
The docs tell the truth now, the benches compile clean,
The tidiest triangulation this warren has seen! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main refactoring work on iterator patterns in the geometry module, aligning with the changeset's core objective.
Description check ✅ Passed The description relates to the changeset by detailing point-generator refactoring, Poisson spacing checks, geometry test distance calculations, and benchmark tracing updates.
Linked Issues check ✅ Passed The PR successfully refactors non-hot collection-building paths to iterator style across multiple files, matching issue #353 acceptance criteria while preserving numerical kernel readability.
Out of Scope Changes check ✅ Passed All changes directly support the stated objectives: iterator refactoring in point generation and geometry tests, benchmark logging separation, and diagnostics example fixes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 100.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/353-iterator-diagnostics

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

@acgetchell acgetchell enabled auto-merge (squash) June 19, 2026 10:38
@codacy-production

codacy-production Bot commented Jun 19, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -10 complexity

Metric Results
Complexity -10

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.01% coverage variation

Metric Results
Coverage variation +0.01% coverage variation (-1.00%)
Diff coverage 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (db46fa2) 69017 63270 91.67%
Head commit (011fb00) 69013 (-4) 63272 (+2) 91.68% (+0.01%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#471) 64 64 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai coderabbitai Bot added documentation Improvements or additions to documentation geometry Geometry-related issues rust Pull requests that update rust code labels Jun 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@benches/common/bench_utils.rs`:
- Around line 32-33: The documentation comment for the `abort_benchmark`
function states it unconditionally emits through tracing, but the actual
implementation at lines 39-40 skips logging when the `bench-logging` feature is
disabled. Update the doc comment to accurately reflect this conditional behavior
by noting that tracing emission only occurs when the `bench-logging` feature is
enabled, or by describing both execution paths for clarity.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 7c238765-803f-467a-b41f-12401d77a44e

📥 Commits

Reviewing files that changed from the base of the PR and between db46fa2 and f4e1135.

📒 Files selected for processing (8)
  • benches/common/bench_utils.rs
  • docs/diagnostics.md
  • src/delaunay/builder.rs
  • src/delaunay/validation.rs
  • src/geometry/algorithms/convex_hull.rs
  • src/geometry/quality.rs
  • src/geometry/util/point_generation.rs
  • tests/proptest_geometry.rs

Comment thread benches/common/bench_utils.rs Outdated
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.65%. Comparing base (db46fa2) to head (011fb00).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #471   +/-   ##
=======================================
  Coverage   91.64%   91.65%           
=======================================
  Files          72       72           
  Lines       68796    68792    -4     
=======================================
+ Hits        63051    63053    +2     
+ Misses       5745     5739    -6     
Flag Coverage Δ
unittests 91.65% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

- Replace manual accumulation loops in geometry diagnostics, quality helpers, point generation, and proptests with iterator adapters.
- Preserve Poisson spacing and scale-aware epsilon invariants while reducing intermediate mutation.
- Standardize Delaunay doctests on DelaunayResult and fix diagnostics validation examples.
- Gate benchmark tracing behind bench-logging and refresh pinned uv, just, rumdl, and semgrep tooling.
@coderabbitai coderabbitai Bot added the enhancement New feature or request label Jun 19, 2026
@acgetchell acgetchell merged commit 1985e6f into main Jun 19, 2026
22 checks passed
@acgetchell acgetchell deleted the refactor/353-iterator-diagnostics branch June 19, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request geometry Geometry-related issues rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: prefer iterators in collection-building paths

1 participant