Repository navigation
Fix per-point speed in adaptive curvature weighting - #259
Conversation
tavateva
left a comment
There was a problem hiding this comment.
Approving. Hold the merge until CI has actually run, though. All three workflows on 60d6855 (PR Test Coverage, Build and Certify Server Image, Build Release Artifacts) are at action_required and waiting for maintainer approval, so nothing has executed on this head yet.
The fix: both np.linalg.norm(first_derivative) calls now use axis=1. The integrand becomes κ·|r'| = |r'×r''|/|r'|² per sample, which is exactly what #258 describes. calculate_arc_length already used per-point norms, and no other caller of the two functions is affected.
Tests: the analytic circle (radius 2, angle t + t²) is the regression #258 asked for, and each of the three tests checks a distinct property: curvature is independent of speed and batch, each sample's contribution equals its turning rate, and the public sampler's progress is uniform in arc length.
- I put
main'sspline.pyunder the new tests: all 3 fail, and the 12 existing spline tests still pass. - At the PR head with
-W error, spline + round-trip regression + metrics gave 26 passed.test/helpers+test/pipeline+ metrics gave 616 passed. The one warning there is starlette's httpx deprecation fromtest_options, which comes from my environment, not this change. flake8 is clean.
Fixture recalibration: I re-measured the tube fixture at this head. The binary centroid distance is 0.118912, matching the PR body, so the bound moving from 0.10 to 0.15 is a geometry change, not a looser tolerance. Every other measurement still clears its bound comfortably. The nearest is the weighted centroid at 0.061 against 0.08, and the binary per-slice maximum actually improved, from 0.536 to 0.505.
PSD trace: the displacement figures (median/max 3.0/15.0 voxels at ratio 0.5, 4.2/26.1 at ratio 1.0) agree with the independent measurement in #258.
Non-blocking:
- Release note location:
release/README.mddocuments the release mechanics, while release notes are published in the GitHub Release body. No release step reads an "Unreleased notes" section, so it relies on someone moving it at release time. It's also underrelease/**, an artifact input, which is why this Python-only fix triggers the release-artifacts workflow. Minimum response: drop the section and add the compatibility line to the v1.6.2 release body when you write it. Keeping it is fine too, as long as release prep moves it into the body and clears it.
Summary
Adaptive slicing used a single norm for the entire derivative batch in both curvature calculations. This changes the normalized curvature contribution from the intended
|r' × r''| / |r'|²to|r' × r''|, making slice placement depend incorrectly on parameter speed. Both norms now operate per point.Closes #258.
t + t²: constant curvature across speeds and batch sizes, correct curvature contributions, and uniform physical progress through the public adaptive sampler.Compatibility note for the v1.6.2 release body
Include this text when preparing the v1.6.2 GitHub Release body; no v1.6.2 release draft exists yet:
Validation
git diff --checkpasses. The review follow-up only removes the README note;release/README.mdis byte-for-byte identical tomain, and norelease/**changes remain in the PR. Python tests were not rerun for this documentation-only follow-up.Validated the actual 77-point PSD trace from
octo9_p7_psd_trace_ouroboros.jsonthrough the production parser and sampler (trace SHA-256:e53d873f1c44472f0002558335130ddead9a3d3fd280443a66866ec2d98d0fe3). Its dense arc length is 5365.361 voxels. At one-voxel spacing, both versions produce 5362 slices:Corrected cumulative curvature matches an independent per-row calculation. Parameters remain finite and nondecreasing with endpoints 0 and 1. Ratio-zero and equidistant parameters and positions are bitwise identical before and after. These measurements confirm the expected placement change; they are not an accuracy-improvement claim.
Shared-basis audit
Inspected the existing
Spline.calculate_adaptive_parameters,calculate_spline_curvature,calculate_curvature_parameterization,adaptive_curvature_parameterization,calculate_arc_length, andSlicesGeometryPipelineSteppath.calculate_spline_curvatureremains the sole production calculation of curvature. The global Frobenius-norm denominator is removed and replaced with each derivative row's speed cubed.calculate_curvature_parameterizationcontinues to consume that curvature and owns its speed weighting and cumulative sum. Its scalar batch-speed path is removed. No persistent speed state, parallel curvature helper, or alternate production formula is introduced.publish-release.yml, andrelease/artifact-inputs.json. The GitHub Release body is the published release-note source; the release README describes mechanics and is also an artifact input. Removed the unconsumedUnreleased notessection instead of adding a new release-preparation step. The compatibility text above is a handoff for the v1.6.2 body, not a second repository changelog. No workflow, artifact-input definition, or version changes are introduced.