Skip to content

Add dim keyword arg to enforce a fixed coordinate length per graph - #13

Merged
petercorke merged 1 commit into
mainfrom
feat/graph-dimension
Sep 3, 2026
Merged

petercorke merged 1 commit into
mainfrom
feat/graph-dimension

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

_BaseGraph.__init__(dim=...) declares that every embedded vertex in this graph must have a coord of exactly that length; add_vertex() checks it and raises ValueError on mismatch. Vertices added with no coord at all are unaffected regardless of dim -- there's nothing to check. Defaults to None (today's fully unconstrained behaviour).

This gives real, validated meaning to what MVTB's BundleAdjust.py has always been trying to express with pgraph.UGraph(6) -- a comment right above that call says "initialize the graph, nodes have 6D coordinates" -- but the arg positional parameter recently removed in the type-hints pass never actually did anything with that 6. It was dead code from the start; dim is the real feature that call was reaching for, now as an explicit, named, and impossible-to-confuse-with-metric keyword arg. (MVTB's call site will need a small follow-up update to UGraph(dim=6) -- tracked separately.)

Test plan

  • New test_dim: valid/invalid dim values, coord-length mismatches, unconstrained (dim=None) graphs, and the coord=None passthrough case
  • 45/45 tests pass
  • Sphinx docs build cleanly; runblock demonstrates the happy path only, matching this file's existing convention of not featuring deliberate failures in executed examples (the ValueError case is documented via :raises: and prose instead)
  • mypy: no new errors (baseline unchanged at 6, all in the pre-existing plot()/highlight_vertex cluster)

_BaseGraph.__init__(dim=...) declares that every embedded vertex in
this graph must have a coord of exactly that length; add_vertex()
checks it and raises ValueError on mismatch. Vertices added with no
coord at all are unaffected regardless of dim -- there's nothing to
check. Defaults to None (today's fully unconstrained behaviour).

This gives real, validated meaning to what MVTB's BundleAdjust.py has
always been trying to express with `pgraph.UGraph(6)` -- a comment
right above that call says "initialize the graph, nodes have 6D
coordinates" -- but the removed `arg` positional parameter never
actually did anything with that 6. It was dead code from the start;
`dim` is the real feature that call was reaching for, now as an
explicit, named, and impossible-to-confuse-with-metric keyword arg.

Verified: valid/invalid dim values, coord-length mismatches, and
unconstrained (dim=None) graphs, including the coord=None passthrough
case. New test_dim. Sphinx runblock demonstrates the happy path only,
matching this file's existing convention of not featuring deliberate
failures in executed examples (the ValueError case is documented via
:raises: and prose instead).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@petercorke
petercorke merged commit 55c4a0c into main Sep 3, 2026
9 checks passed
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.05%. Comparing base (f67cec7) to head (c05c226).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
+ Coverage   84.95%   85.05%   +0.09%     
==========================================
  Files           2        2              
  Lines         771      776       +5     
==========================================
+ Hits          655      660       +5     
  Misses        116      116              

☔ 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.

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