Skip to content

📝 docs(spec): specify chord_distance and interval - #732

Merged
nstarman merged 2 commits into
GalacticDynamics:mainfrom
nstarman:claude/spec-verb-coverage
Aug 18, 2026
Merged

📝 docs(spec): specify chord_distance and interval#732
nstarman merged 2 commits into
GalacticDynamics:mainfrom
nstarman:claude/spec-verb-coverage

Conversation

@nstarman

Copy link
Copy Markdown
Contributor

Of the manifold measurement verbs, norm, angle_between and geodesic_distance each carry a software-spec-* section. chord_distance (#720) never had one, and interval had eight passing mentions but no entry of its own. Both are public and reachable as cx.*; neither was specified.

chord_distance

Placed directly after geodesic_distance, since the two are a pair — same signature shape, opposite question.

The part worth having written down is the return type:

manifold geodesic_distance chord_distance
HyperSphericalManifold (unit sphere) Angle in rad dimensionless Quantity
EmbeddedManifold, TwoSphereIn3D(radius=Q(2, "m")) Distance in m Distance in m

That asymmetry is deliberate and easy to mistake for a bug: an arc is an angle, a chord is not, and the bare manifold has no length scale, so its chord is a pure ratio. Consistent with the reasoning in #716 for the intrinsic metric being dimensionless.

interval

Leads with what it is for — the signed form is defined where norm has no real value and geodesic_distance refuses outright — then states plainly that it is not a distance. Unlike the other four verbs it is neither chart-invariant nor symmetric, and I measured both rather than asserting them:

same two points, flat plane:  interval          cart2d 5.0 m²    polar2d 3.467 m²
                              geodesic_distance        2.236 m           2.236 m

sph2, one pair:               interval (a,b) 0.813 rad²   (b,a) 0.999 rad²

So interval == geodesic_distance**2 holds only on a flat manifold in Cartesian coordinates — flatness alone is not enough, because a curvilinear chart on flat space has a varying metric. That is the same correction #724 made to the docstrings, now stated where the contract lives.

Also updates geodesic_distance's "sits alongside norm and angle_between as the third manifold measurement", which stopped being complete when chord_distance landed, and cross-links the two.

Verification

Every example was executed before being written down, because nothing in CI would catch a wrong one: docs/spec.md is excluded from pytest via --ignore-glob=docs/spec.md. Three reprs were wrong on the first pass — Quantity(Array(-24., dtype=float32), unit='m2') rather than Q(-24., 'm2') — and only running them found it.

  • All 20 new example lines pass, verified both standalone and under the repo's own sybil harness
  • uv run --frozen nox -s docs (warnings as errors): build succeeded, cross-link resolves
  • prek run --all-files clean (blacken-docs reformatted the blocks; re-verified after)

Found while here, deliberately not fixed

That --ignore-glob is hiding real rot. Running the file anyway:

17 failed, 277 passed

The 17 are stale outputs, mostly weak_type=True reprs, plus one NameError: name 'manifold' is not defined. None are in the sections this PR adds. It looks like the exclusion could be dropped once those are fixed, which would put all 303 example lines under CI — but that is a separate change from adding two entries, and mixing them would bury this diff. Happy to open it as a follow-up.

Also still unspecified: causal_character, proper_time and proper_distance in the lorentzian sub-namespace, and the plumbing verbs (metric_matrix at 26 mentions is the largest). Left out to keep this to the two measurement verbs.

🤖 Generated with Claude Code

Of the manifold measurement verbs, `norm`, `angle_between` and
`geodesic_distance` each carry a `software-spec-*` section; `chord_distance`
(GalacticDynamics#720) never had one, and `interval` had eight passing mentions but no entry of
its own. Both are public, both are reachable as `cx.*`, and neither was
specified.

`chord_distance` follows the `geodesic_distance` entry, since the two are a
pair: same signature shape, opposite question. Its section records that the
result carries the ambient's length unit for an `EmbeddedManifold` but is
*dimensionless* on the bare `HyperSphericalManifold` -- whose canonical
embedding is the unit sphere, so the chord is a pure ratio. That is a real
asymmetry with `geodesic_distance`, which returns an `Angle` on the same
manifold, and it is the sort of thing a spec exists to pin: an arc is an angle,
a chord is not.

`interval`'s section leads with what it is for -- the signed form is defined
where `norm` has no real value and `geodesic_distance` refuses outright -- and
then states plainly that it is **not** a distance. It is neither chart-invariant
nor symmetric, and both were measured rather than asserted:

    same two points, flat plane:  cart2d 5.0 m^2   polar2d 3.467 m^2
                                  geodesic_distance 2.236 m in both
    sph2, one pair:               (a,b) 0.813 rad^2  (b,a) 0.999 rad^2

So `interval == geodesic_distance**2` holds only on a flat manifold *in
Cartesian coordinates*; flatness alone is not enough, since a curvilinear chart
on flat space has a varying metric. Same correction GalacticDynamics#724 made to the docstrings,
now stated where the contract lives.

Also updates `geodesic_distance`'s "sits alongside `norm` and `angle_between` as
the third manifold measurement", which stopped being complete when
`chord_distance` landed, and cross-links the two.

Every example was executed before being written down. `docs/spec.md` is excluded
from pytest via `--ignore-glob`, so nothing in CI would have caught a wrong one
-- three reprs were wrong on the first pass (`Quantity(Array(-24., ...))` rather
than `Q(-24., 'm2')`) and only running them found it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 18, 2026 20:04
@github-actions github-actions Bot added the 📝 Add / update documentation Add or update documentation. label Aug 18, 2026

Copilot AI 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.

Pull request overview

Adds missing authoritative spec entries in docs/spec.md for two public manifold measurement verbs (chord_distance and interval), and updates the surrounding geodesic_distance spec text to cross-link the new contract.

Changes:

  • Add a new software-spec-chord_distance section defining semantics, dispatch behavior, return types, and examples.
  • Add a new software-spec-interval section clarifying purpose/limitations (chart dependence, asymmetry) plus signatures and examples.
  • Update geodesic_distance prose to reference chord_distance as the paired ambient-space measurement.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/spec.md
Comment thread docs/spec.md Outdated
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.56%. Comparing base (5b65408) to head (48c7bce).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #732      +/-   ##
==========================================
+ Coverage   96.46%   96.56%   +0.10%     
==========================================
  Files         266      266              
  Lines        8738     8852     +114     
==========================================
+ Hits         8429     8548     +119     
+ Misses        309      304       -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.

Review caught that the bullet asserted `norm(b - a)**2 == interval(a, b)`, which
is not executable: `CDict` is a plain mapping, so `b - a` raises `TypeError:
unsupported operand type(s) for -: 'dict' and 'dict'`, and `norm` needs the
chart and the `at=` that fixes where the metric is evaluated. Loose prose
carried over from the source comment, which is fine in a comment and not in a
normative contract.

The identity itself holds. Now stated with the component-wise `diff` and the
base point spelled out, and demonstrated on `sph3d` -- a chart whose metric
genuinely varies, so the example would fail if `at=` were dropped rather than
passing for a constant-metric reason:

    norm(diff, sph3d, at=a) ** 2  ->  Q(1.629626, 'm2')
    interval(sph3d, a, b)         ->  Q(1.629626, 'm2')

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@nstarman nstarman added this to the v0.24.0 milestone Aug 18, 2026
@nstarman
nstarman merged commit 9ebf3fb into GalacticDynamics:main Aug 18, 2026
17 checks passed
@nstarman
nstarman deleted the claude/spec-verb-coverage branch August 18, 2026 21:26
nstarman added a commit to nstarman/coordinax that referenced this pull request Aug 18, 2026
Review caught explanatory sentences sitting inside ```pycon blocks. Everything
in a fence renders as code, so those lines came out monospaced and their inline
markup -- ``x/y/z``, *names* -- rendered literally.

Fixed by closing the fence around the prose rather than by prefixing it with
`>>> #`, which would have kept it inside the block and dropped the markup
entirely instead of just failing to render it.

Six occurrences, not the one flagged: one is this branch's, four came in with
GalacticDynamics#732, and `Points move by ``delta * tau``` predates both. Same defect and the
same file, and this is the branch that puts the file under CI, so fixing the
class rather than the instance belongs here.

Sibling fences are fine for sybil -- the namespace is per document, so state
carries across the split. (Nesting a fence inside an admonition is what raises
`ValueError: <Region ...> overlaps <Region ...>`; that is a different shape and
not what this does.)

300 passed, `prek run --all-files` clean, docs build succeeds.
nstarman added a commit to nstarman/coordinax that referenced this pull request Aug 18, 2026
Review caught explanatory sentences sitting inside ```pycon blocks. Everything
in a fence renders as code, so those lines came out monospaced and their inline
markup -- ``x/y/z``, *names* -- rendered literally.

Fixed by closing the fence around the prose rather than by prefixing it with
`>>> #`, which would have kept it inside the block and dropped the markup
entirely instead of just failing to render it.

Six occurrences, not the one flagged: one is this branch's, four came in with
GalacticDynamics#732, and `Points move by ``delta * tau``` predates both. Same defect and the
same file, and this is the branch that puts the file under CI, so fixing the
class rather than the instance belongs here.

Sibling fences are fine for sybil -- the namespace is per document, so state
carries across the split. (Nesting a fence inside an admonition is what raises
`ValueError: <Region ...> overlaps <Region ...>`; that is a different shape and
not what this does.)

300 passed, `prek run --all-files` clean, docs build succeeds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📝 Add / update documentation Add or update documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants