Add dim keyword arg to enforce a fixed coordinate length per graph - #13
Merged
Merged
Conversation
_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>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_BaseGraph.__init__(dim=...)declares that every embedded vertex in this graph must have acoordof exactly that length;add_vertex()checks it and raisesValueErroron mismatch. Vertices added with nocoordat all are unaffected regardless ofdim-- there's nothing to check. Defaults toNone(today's fully unconstrained behaviour).This gives real, validated meaning to what MVTB's
BundleAdjust.pyhas always been trying to express withpgraph.UGraph(6)-- a comment right above that call says "initialize the graph, nodes have 6D coordinates" -- but theargpositional parameter recently removed in the type-hints pass never actually did anything with that6. It was dead code from the start;dimis the real feature that call was reaching for, now as an explicit, named, and impossible-to-confuse-with-metrickeyword arg. (MVTB's call site will need a small follow-up update toUGraph(dim=6)-- tracked separately.)Test plan
test_dim: valid/invaliddimvalues, coord-length mismatches, unconstrained (dim=None) graphs, and thecoord=Nonepassthrough caseValueErrorcase is documented via:raises:and prose instead)plot()/highlight_vertexcluster)