Repository navigation
fix: Edge.v1 and Edge.v2 are read-only - #39
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
They were plain attributes, so e.v1 = None on an edge that was in a graph left it wedged: remove_edge and remove_vertex raised, incidence() hit an assert, and the edge could not be removed. Assigning to one of them to another vertex left the edge disagreeing with the vertices' edge lists. Only the library binds an edge to its vertices -- the constructor, connect(), and remove_edge() -- so they are now properties over private fields, set through one method, and assigning raises AttributeError saying to use the constructor or connect() instead. An edge that is in a graph always has both of its ends. The downstream Edge subclasses (MVTB Observation, RTB LatticeEdge and PGEdge) all call super().__init__(v1, v2), and nothing in RTB, MVTB, RVC3 or spatialmath assigns an endpoint. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 18 |
| Duplication | 1 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #39 +/- ##
==========================================
+ Coverage 93.79% 93.86% +0.07%
==========================================
Files 3 3
Lines 1063 1076 +13
==========================================
+ Hits 997 1010 +13
Misses 66 66 ☔ 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
Edge.v1andEdge.v2were plain attributes, soe.v1 = Noneon an edge that was in a graph left it wedged:remove_edgeandremove_vertexraised,incidence()hit an assert, and the edge could not be removed. Assigning one of them to another vertex left the edge disagreeing with the vertices' edge lists.Only the library binds an edge to its vertices (the constructor,
connect()andremove_edge()), so they are now read-only properties over private fields, set through one private method. Assigning raisesAttributeErrorsaying to use the constructor orconnect()instead. An edge that is in a graph always has both of its ends.Breaking change (1.0)
Code that assigned
edge.v1/edge.v2now getsAttributeError. I audited RTB, MVTB, RVC3 and SMTB: nothing assigns an endpoint, and all three downstreamEdgesubclasses (MVTBObservation, RTBLatticeEdgeandPGEdge) callsuper().__init__(v1, v2, ...).Tests
tests/test_edge_endpoints.py: assignment is refused (to a vertex and toNone), the graph is left untouched by the attempt, and the library can still bind, connect and remove.🤖 Generated with Claude Code