Skip to content

fix(plot): honour the three-state block contract - #2

Closed
huxiaoyi-ovo wants to merge 28 commits into
mainfrom
fix/plot-block-contract-79
Closed

huxiaoyi-ovo wants to merge 28 commits into
mainfrom
fix/plot-block-contract-79

Conversation

@huxiaoyi-ovo

@huxiaoyi-ovo huxiaoyi-ovo commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Fork-only validation for pgraph-python #79; not intended to be merged into the fork.

Change

  • Graph.plot() and Graph.highlight_path() now default to block=None, leaving figure display to the environment. Explicit False and True retain their existing show semantics.
  • Update docstrings, the README script example, and docs/llms_intro.md.
  • Add Matplotlib Agg regression tests covering no implicit plt.show, explicit block=False/True, and same-axes highlighting.

Verification

  • Based directly on upstream main at 74402d5.
  • Four commits; exactly four files changed, independently of other pgraph PRs.
  • All fork CI checks passed: all Python 3.9–3.14 tests, mypy and Codecov; docs deploy skipped by workflow policy.
  • Python 3.12 test matrix: 774 passed including three new regressions.
  • The default change is intentional. Scripts that want immediate display should use block=False or call plt.show() after drawing all overlays.

Upstream submission

Issue petercorke#79 has been claimed by huxiaoyi-ovo. No duplicate upstream PR found. Ready to submit upstream via GitHub website, because the integration lacks cross-repository PR creation permissions (GitHub API 403).

AI assistance: ChatGPT (OpenAI GPT-6) helped review, implement and test this change.

petercorke and others added 6 commits October 14, 2026 08:36
…etercorke#74)

Without a k-d tree both measured the metric of every vertex in a Python
loop, and any add_vertex discarded the tree, so a planner that interleaves
add_vertex with closest (RTB's LatticePlanner, RRTPlanner) always paid for
the loop.

The graph now keeps the coordinates of its embedded vertices as a matrix,
built on first use and appended to by add_vertex, and applies the built-in
metrics to all rows at once.  Removing a vertex or assigning a coord drops
it.  A metric of your own is still applied to each vertex in turn.  It is
not pickled or copied, and has its own staleness flag.

closest at N=1,000: 726 us -> 12 us.  Lattice plan of 1,292 vertices: 1.07 s
-> 0.06 s.  Vertices, edges and paths of the RTB planners are unchanged.

A coordinate changed in place (v.coord[0] = x) is not seen, as with
build_kdtree(); documented.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Agents choosing between packages need to know what this one is for and
what it is not for, and users phrase problems as tasks, not API names.
llms_intro.md gains a "When to use it" section (including what it is not
for) and a "Recipes" section of task-phrased one-liners, each checked
against the current code. pyproject.toml gains a project URL for
llms.txt so it is discoverable from the PyPI page.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Align plot() and highlight_path() with the RVC block contract without changing explicit True/False handling.

Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>
Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>
Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>
Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>

Copy link
Copy Markdown
Owner Author

Fork-only validation complete: all required CI checks passed. The same head commit has been submitted upstream as petercorke#84. Closing this staging draft PR to keep the fork tidy; the upstream PR and source branch remain unchanged.

Co-Authored-By: ChatGPT (OpenAI GPT-6) <noreply@openai.com>
Vamsi-2581 and others added 19 commits October 31, 2026 11:01
The graph had two __repr__ definitions in one class.  The first returned
str(self) and was shadowed by the second, which printed one line per vertex,
so a repr (a notebook cell, a debugger, a log line, an error message) was as
long as the graph.  A type: ignore[no-redef] hid the redefinition.

Keep one __repr__, the same one-line summary as __str__, and have show()
print what the long repr did: each vertex with its name, coordinate and
component number.  plot() and show() now refer to each other in :seealso:.

Part of petercorke#23.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…elper

Fourteen of the sixteen assert statements in PGraph.py only told mypy that an
optional value was set: the ends of an edge (v1 and v2 are None until it is
connected) and the name of a vertex (None until it is in a graph).  Bandit
reports each as B101, and python -O removes them.

Add Edge._ends(), which returns both vertices or raises ValueError, and
Vertex._require_name(), which returns the name or raises ValueError, in the
manner of Graph._require_cost().  They replace the asserts, so the narrowing
is still there for mypy and the check is a real one.  The two asserts left
(the coordinate of a candidate in near(), the graph in Vertex.connect()) are
type narrowing too, and are marked # nosec B101.

A connected edge behaves as before.  An unconnected one, which no graph
holds, now raises ValueError from endpoints and next() instead of
AssertionError (or, from next(), "should not happen").

Part of petercorke#23.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Delete posegraph.py, a 2020 prototype in the repository root that nothing
  uses: it imports the deprecated UVertex, has a stub method and debug prints,
  and needs itertools.pairwise (Python 3.10) in a package that supports 3.9.
  The Robotics Toolbox has the real PoseGraph.
- examples/create_json.py: pop('dgoal', None) instead of a bare except.
- Pin the two remaining third-party GitHub Actions to commit SHAs with the
  version in a comment, as RTB did in petercorke/robotics-toolbox-python#892:
  codecov/codecov-action v7.1.1 and dependabot/fetch-metadata v3.1.0.  They are
  the commits that @v7 and @V3 point to today, so what runs is unchanged.
  GitHub's own actions/* stay on tags, and Dependabot updates a pinned SHA with
  its comment.
- Ignore build/ as well as docs/build and dist/.

Part of petercorke#23.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Edge.__str__ (and so repr) used "--" and "->".  Use ↔ for an undirected
edge and → for a directed one.  The DOT exporter is unchanged: GraphViz
needs ASCII.  The saved outputs in examples/roads.ipynb are updated.

Fixes petercorke#76

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
fix: repr(g) is the one-line summary, show() lists the vertices
…-helpers

refactor: narrow optional edge ends and vertex names with a checked helper
…eftovers

chore: housekeeping leftovers from the Codacy cleanup
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rows

feat(edge): show ↔ and → between the ends of an edge
docs(llms): add 'when to use it' and recipes, link llms.txt from PyPI
perf: closest() and near() use a matrix of coordinates, not a loop
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.14.2 to 1.14.3.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](pypa/gh-action-pypi-publish@dc37677...7245906)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-version: 1.14.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
github-actions Bot and others added 2 commits November 1, 2026 07:47
…tions/pypa/gh-action-pypi-publish-1.14.3

chore(deps): bump pypa/gh-action-pypi-publish from 1.14.2 to 1.14.3
@huxiaoyi-ovo huxiaoyi-ovo reopened this Nov 2, 2026
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.

3 participants