Skip to content

fix: CameraBase.plot() unbound call (self=None) crashed instead of working - #90

Merged
petercorke merged 6 commits into
mainfrom
fix/camera-plot-unbound-call
Aug 16, 2026
Merged

petercorke merged 6 commits into
mainfrom
fix/camera-plot-unbound-call

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

  • CentralCamera.plot(pose=..., scale=...) -- called unbound on the class, no instance -- is a real usage pattern (e.g. RVC3-python's chap13 notebook plots calibration frames from images2C() this way), signalled by plot()'s own self=None default, but never actually worked: self._plot_frustum()/self._plot_camera_icon() require a bound self, so it always raised AttributeError: 'NoneType' object has no attribute '_plot_camera_icon'.
  • _plot_frustum()/_plot_camera_icon() never used self at all, so made them @staticmethod and call them via CameraBase directly.
  • Also fixed: the frame=True/frame=<dict> block used self.pose instead of the passed-in pose, so a bound call with an explicit pose different from the instance's own pose silently drew the frame overlay in the wrong place.
  • Unbound calls with no pose now raise a clear ValueError instead of the confusing AttributeError.
  • Docstring rewritten to document both calling forms explicitly.

Test plan

  • tests/test_camera.py::TestCameraPlot -- added test_plot_unbound_with_pose (asserts icon collections actually get added) and test_plot_unbound_without_pose_raises; all 5 TestCameraPlot tests pass
  • Full test suite: 810 passed, 72 skipped, no regressions
  • Manually verified against RVC3-python's chap13.ipynb notebook cell (for frame in frames: CentralCamera.plot(pose=frame.pose, scale=0.05))

🤖 Generated with Claude Code

…rking

CentralCamera.plot(pose=..., scale=...) -- called on the class itself,
with no instance -- is a real, book-used pattern for plotting camera
icons at a set of poses that don't belong to any single camera instance
(eg. calibration frames from images2C()). The self=None default made
this look supported, but self._plot_frustum()/self._plot_camera_icon()
required a bound self, and frame=True used self.pose instead of the
passed-in pose, so the unbound form always raised AttributeError.

_plot_frustum() and _plot_camera_icon() never actually used self, so
made them staticmethods and call them via CameraBase directly; the
frame block now uses pose instead of self.pose. Unbound calls with no
pose now raise a clear ValueError instead of an AttributeError.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

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.

@petercorke
petercorke merged commit 0371b81 into main Aug 16, 2026
29 checks passed
@petercorke
petercorke deleted the fix/camera-plot-unbound-call branch October 3, 2026 14:47
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