📝 fix(manifolds): correct the docs that still describe the old separation - #724
Conversation
There was a problem hiding this comment.
Pull request overview
Updates documentation and test naming around the separation → geodesic_distance refactor, correcting remaining prose that still described the old “norm of coordinate difference” behavior and clarifying when interval matches a squared distance.
Changes:
- Update API/docs text to describe
geodesic_distanceas a manifold-geodesic (and refusal behavior) rather than a coordinate-difference norm. - Correct claims that
interval == geodesic_distance**2in general by narrowing the condition to flat/Cartesian, and add a curved counterexample test. - Rename remaining tests/classes from “separation” to “geodesic_distance” (plus associated docstrings/comments).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/vectors/test_point.py | Renames Point-level tests to geodesic_distance (docstrings still contain a few “Separation” references). |
| tests/unit/manifolds/test_interval.py | Renames the “squared separation” test and adds a curved-space counterexample. |
| tests/unit/manifolds/test_geodesic_distance_dispatch.py | Renames test classes/methods to reflect geodesic_distance. |
| tests/unit/charts/test_jit_parameterized_paths.py | Renames the JIT test for geodesic_distance. |
| src/coordinax/manifolds/lorentzian.py | Clarifies interval-sign discussion for non-Lorentzian signatures. |
| src/coordinax/_src/manifolds/interval.py | Updates internal commentary to distinguish norm(diff) vs geodesic_distance. |
| packages/coordinaxs.api/src/coordinaxs/api/manifolds.py | Updates abstract API docstrings for geodesic_distance and interval. |
Suppressed comments (7)
tests/unit/manifolds/test_interval.py:70
- In the new curved-space counterexample,
sep2still carries the old "separation" naming. Renaming it togd2(or similar) would make it clear this isgeodesic_distance(...)**2.
ds2 = float(cxm.interval(cxc.sph2, a, b).ustrip("rad2"))
sep2 = float(cxm.geodesic_distance(cxc.sph2, a, b).ustrip("rad")) ** 2
assert ds2 < sep2
assert ds2 == pytest.approx(0.7335, abs=1e-3)
assert sep2 == pytest.approx(0.8430, abs=1e-3)
tests/unit/vectors/test_point.py:293
- This docstring still uses the old term "Separation" after the
geodesic_distancerename. Updating it keeps the test documentation consistent with the current API name.
def test_geodesic_distance_is_chart_invariant(self):
"""Separation does not depend on the chart of either operand."""
p = cx.Point.from_([3.0, 0.0, 0.0], "m")
q = cx.Point.from_([0.0, 4.0, 0.0], "m").cconvert(cxc.sph3d)
assert bool(qnp.isclose(cx.geodesic_distance(p, q).ustrip("m"), 5.0))
tests/unit/vectors/test_point.py:299
- This docstring still says "Separation" even though the test is now about
geodesic_distance.
def test_geodesic_distance_is_unit_invariant(self):
"""Separation does not depend on the component units."""
p = cx.Point.from_([3.0, 0.0, 0.0], "m")
q = cx.Point.from_([0.0, 0.004, 0.0], "km")
assert bool(qnp.isclose(cx.geodesic_distance(p, q).ustrip("m"), 5.0))
tests/unit/vectors/test_point.py:313
- This docstring still references
separation_3d, which is tied to the removed/renamed API. Consider rephrasing to avoid the oldseparationterminology.
def test_geodesic_distance_dimensionality_follows_manifold(self):
"""2-D points give a 2-D distance -- no separate ``separation_3d``."""
p = cx.Point.from_([3.0, 0.0], "m")
q = cx.Point.from_([0.0, 4.0], "m")
assert bool(qnp.isclose(cx.geodesic_distance(p, q).ustrip("m"), 5.0))
tests/unit/vectors/test_point.py:319
- This docstring still uses the old term "Separation" even though the test now targets
geodesic_distance.
def test_geodesic_distance_different_frames_raises(self):
"""Separation across frames is undefined without alignment."""
p = cx.Point.from_([1.0, 0.0, 0.0], "m", cxf.alice)
q = cx.Point.from_([0.0, 1.0, 0.0], "m", cxf.noframe)
with pytest.raises(ValueError, match="frame"):
tests/unit/vectors/test_point.py:333
- This docstring still uses "Separation" terminology; updating it keeps test docs consistent with
geodesic_distance.
def test_geodesic_distance_unitless_components(self):
"""Separation works for vectors with plain (unitless) array leaves."""
p = cx.Point.from_({"x": 3.0, "y": 0.0, "z": 0.0}, cxc.cart3d)
q = cx.Point.from_({"x": 0.0, "y": 4.0, "z": 0.0}, cxc.cart3d)
assert bool(qnp.isclose(cx.geodesic_distance(p, q), 5.0))
tests/unit/vectors/test_point.py:305
- This docstring still uses the old term "Separation" after renaming the test to
geodesic_distance.
def test_geodesic_distance_elementwise_over_batch(self):
"""Separation is evaluated element-wise over the batch."""
p = cx.Point.from_([[3.0, 0, 0], [1, 0, 0]], "m")
q = cx.Point.from_([[0.0, 4, 0], [0, 1, 0]], "m")
d = cx.geodesic_distance(p, q)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #724 +/- ##
=======================================
Coverage 96.55% 96.55%
=======================================
Files 265 265
Lines 8793 8793
=======================================
Hits 8490 8490
Misses 303 303 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ation` GalacticDynamics#715 replaced `separation` with `geodesic_distance` and made it a real manifold-geometric quantity. The prose did not follow it everywhere. The abstract `geodesic_distance` docstring still defined it as "the manifold `norm` of the two points' coordinate difference" -- the implementation GalacticDynamics#715 removed, and one that is asymmetric on a curved manifold and so is not a distance at all. It now says what the function computes: the shortest path along the manifold, from the manifold's geometry, refusing rather than approximating where no closed form exists. `interval` is the quadratic form of the coordinate difference, and the square root belongs to `norm` alone -- `geodesic_distance` is computed from geometry and is not generally the root of anything the coordinate difference gives. It equals `geodesic_distance**2` only where the metric is constant along the path. Flatness alone does not buy that, which the docs asserted in three places. The condition is on the *chart* as well as the manifold: `polar2d` charts the same flat plane, and for one pair of points gives interval[cart2d] = 5.0000 interval[polar2d] = 3.4674 geodesic**2 = 5.0000 Corrected in the abstract docstring, the `interval` module docstring, and `docs/api/manifolds.md`, with a test pinning the polar case so the claim cannot rot back. The curved-manifold case is pinned too: on the unit sphere at ~0.92 rad the two differ by 13% (0.7335 against 0.8430), the sphere's metric being positive-definite yet not constant -- so the fork is flatness, not definiteness, which is what the old test name asserted. `lorentzian`'s module docstring claimed that without a Lorentzian signature "the interval has the same sign for every pair". True only for a definite metric; an indefinite one with more than one timelike direction has varying signs, it simply does not partition pairs into past, future, and elsewhere. The same false invariant GalacticDynamics#701 removed from the refusal messages, which survived in the prose. Test names still said `separation` after the rename: `TestSeparationDispatches`, `TestIndefiniteMetricSeparation`, `test_euclidean_separation_is_unaffected`, `test_jit_separation_in_parameterized_chart`, and `TestPointSeparation` with its eight methods -- whose docstrings still said "Separation" and described the class as measuring a "manifold-norm" distance. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
aa58c3e to
94493ad
Compare
* 📝 docs(spec): specify `chord_distance` and `interval` 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, 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 #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. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Split out of #720 so fixes stay separate from features. Docs and test names only — no behaviour change.
#715 renamed
separationtogeodesic_distanceand gave it real geodesics, but four pieces of prose still describe the function it replaced.The abstract dispatch still documented the removed definition
coordinaxs.api.manifolds.geodesic_distanceread:That is precisely what #715 removed, for being asymmetric on a curved manifold and therefore not a distance. The API's own contract was still advertising the behaviour the implementation now refuses.
interval == geodesic_distance**2is no longer trueTwo more places claimed it for any Riemannian metric. True when
geodesic_distancewas that norm; false now:The identity is with
norm(diff), and the condition is flatness, not positive-definiteness — the sphere's metric is positive-definite and it still fails.A test asserted the same over-general claim in its name and docstring (
test_riemannian_interval_is_squared_separation, "for a positive-definite metric the two agree") while only ever exercising flat space, so it passed. It now says flat, and a curved counter-case pins the distinction.Smaller
lorentzian's module docstring said that without a Lorentzian signature "the interval has the same sign for every pair". True only for positive-definite metrics — an indefinite metric with two timelike directions varies in sign without defining causal structure.separation.Verification
prek run --all-filescleanFound while splitting #720: cherry-picking onto clean
mainput the file in front of me without my own edits layered on top, which is what made the stale text visible.🤖 Generated with Claude Code