Skip to content

fix: restore pvplus.py, fix pyvista API drift, drop rvcprint from figure scripts - #44

Open
petercorke wants to merge 3 commits into
mainfrom
fix/restore-pvplus-issue-20
Open

fix: restore pvplus.py, fix pyvista API drift, drop rvcprint from figure scripts#44
petercorke wants to merge 3 commits into
mainfrom
fix/restore-pvplus-issue-20

Conversation

@petercorke

@petercorke petercorke commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #20. tools/pvplus.py was a symlink to a path on the reporter's old machine that never existed in this repo — every figures/**/*.py script doing import pvplus was broken.

  • Recovered the file content (3 near-identical copies supplied, differing in one line) and placed it at RVC3/tools/pvplus.py, not bare tools/ or figures/3d/: it's imported by ~40 scripts across figures/3d/ and several figures/code/chapterN/ subdirectories, and RVC3.tools is already a real, pip-installable package — the only placement that resolves for every consumer via a normal pip install -e . dev setup, no PYTHONPATH needed.
  • Swapped import pvplusfrom RVC3.tools import pvplus in all 40 consuming scripts (mechanical, one line each).
  • Fixed outfile()'s hardcoded personal absolute path to derive from the calling script's own location — same class of bug as the original issue.
  • Fixed pyvista's PolyData.transform() now requiring an explicit inplace= kwarg (used to default to True) at all 7 call sites in pvplus.py, discovered while actually testing this against a current pyvista install.
  • Removed the now-fully-unused rvcprint import from the 6 figures/3d/*.py scripts that had it (figures/3d/README.md confirms these scripts save output via plotter.export_gltf(...) directly, never via rvcprint). Left the figures/code/chapterN/ copies of these scripts untouched — figures/code/README.md documents rvcprint as the required mechanism those scripts use to save the book's actual PDF figures, so it was never broken there and out of scope for this fix.
  • Adds a figures optional-dependency extra (pyvista, vtk, pillow) to pyproject.toml — previously undeclared anywhere. pip install -e ".[figures]" is now the way to get set up for regenerating book figures.

Left alone, out of scope here: several individual figure scripts (mostly the fig7_* arm-kinematics figures, and fig2_24.py) have their own local .transform() calls with the same pyvista API-drift issue.

Test plan

  • All 40 modified scripts pass py_compile
  • 9 of the pvplus-consuming scripts run end-to-end (add_frame, ribbon, axis, add_ellipsoid, ellipsoid_3d, add_frame2 all exercised), all exit 0
  • 3 more open a real on-screen render window (no off_screen=True) — confirmed rendering correctly by eye, not run to completion headlessly
  • figures/code/chapterN/ copies confirmed byte-identical to origin/main apart from the one-line pvplus import fix

…ure scripts

Fixes #20. tools/pvplus.py was a symlink to a path on the reporter's old
machine (/Users/corkep/Dropbox/.../frames.py) that never existed in this
repo or anywhere accessible -- every figures/**/*.py script that did
`import pvplus` was broken for anyone but the original author, and only
by cwd accident even then.

Recovered the file's content (three near-identical copies existed, all
but one line identical) and placed it at RVC3/tools/pvplus.py instead of
bare tools/ or figures/3d/: it's imported by ~40 scripts spread across
figures/3d/ and multiple figures/code/chapterN/ subdirectories, and
RVC3.tools is already a real, declared, pip-installable package -- the
only placement that resolves for every consumer via a normal
`pip install -e .` dev setup, with no PYTHONPATH tweaking needed.

Swapped `import pvplus` -> `from RVC3.tools import pvplus` in all 40
consuming scripts (mechanical, one line each -- every pvplus.xxx(...)
call site is unchanged since the bound name doesn't change). Also fixed
outfile()'s hardcoded personal absolute path to derive from the calling
script's own location -- same class of bug as the original issue, no
reason to reintroduce it.

Testing this surfaced two more real, pre-existing issues:
- pyvista's PolyData.transform() now requires an explicit inplace=
  kwarg (used to default to True) -- added it at all 7 call sites in
  pvplus.py so it actually runs against a current pyvista install.
  Several individual figure scripts have their own local .transform()
  calls with the same issue; left those alone, out of scope here.
- Several scripts import a book-production image-export helper
  (rvcprint) that's either equally broken (bare `import rvcprint` /
  `from rvcprint import outfile`) or just unnecessary for what we're
  testing here. Commented it out (import + the screenshot-path usage)
  in the ~10 pvplus-consuming scripts that referenced it, per
  discussion -- it's book-production plumbing, not needed to exercise
  the actual figure-generation logic.

Adds a `figures` optional-dependency extra (pyvista, vtk, pillow) to
pyproject.toml, since none of this was previously declared anywhere --
`pip install -e ".[figures]"` is now the documented way to get set up
for regenerating book figures.

## Test plan
- All 40 modified scripts pass `py_compile`
- Ran 9 of the pvplus-consuming scripts end-to-end (add_frame, ribbon,
  axis, add_ellipsoid, ellipsoid_3d, add_frame2 all exercised), all
  exit 0
- 3 more (fig2_15.py, fig2_16.py, fig9_17.py in figures/code/) open a
  real on-screen render window since they don't set off_screen=True --
  confirmed rendering correctly by eye, not run to completion
  headlessly
Correction to the previous commit, which touched rvcprint in some
figures/code/chapterN/ scripts too. figures/code/README.md documents
that rvcprint is the required, intentional mechanism those scripts use
to save the book's PDF figures -- it was never broken there and
shouldn't have been touched. Reverted those 6 files back to their
original state (only the pvplus import fix remains).

For the 6 figures/3d/*.py scripts that reference rvcprint (the tree
issue #20 is actually about): none of them use it for their real
output mechanism (they all call plotter.export_gltf(...) directly,
confirmed by figures/3d/README.md), so removed the now-fully-unused
import from each rather than leaving a disabled trace of it.
rvcpython -> rvc3python (doesn't exist on PyPI; rvc3python does, and
matches pyproject.toml's declared name).
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.

import pvplus is missing

1 participant