From 807e9c0b983710ecde8f5fbac803150e73713477 Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Thu, 26 Nov 2026 05:43:18 +1000 Subject: [PATCH 1/4] fix: disp(notebook=True) names an option that Plotly cannot draw Plotly accepts a subset of the options of the Open3D window, and point_show_normal is not among them. The call failed with an error from inside get_plotly_fig. It now raises TypeError that names the option and lists those that are accepted. Co-Authored-By: Claude Sonnet 5.5 --- src/machinevisiontoolbox/PointCloud.py | 10 ++++++++++ tests/test_pointcloud.py | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/machinevisiontoolbox/PointCloud.py b/src/machinevisiontoolbox/PointCloud.py index c37c2e1e..a6284e25 100644 --- a/src/machinevisiontoolbox/PointCloud.py +++ b/src/machinevisiontoolbox/PointCloud.py @@ -21,6 +21,7 @@ """ import difflib +import inspect from pathlib import Path from typing import Any, Callable from warnings import warn @@ -55,6 +56,15 @@ def _show_in_notebook( """ if file is not None: raise ValueError("file cannot be used with notebook=True") + # Plotly draws a subset of the options of the Open3D window, so name an option + # that it does not accept, instead of leaving it to fail in get_plotly_fig + supported = set(inspect.signature(o3d.visualization.get_plotly_fig).parameters) + unsupported = sorted(set(kwargs) - supported) + if unsupported: + raise TypeError( + f"disp(notebook=True) does not support the option(s) {unsupported}; " + f"the options it accepts are {sorted(supported - {'geometry_list'})}" + ) try: import plotly # noqa: F401 except ImportError: diff --git a/tests/test_pointcloud.py b/tests/test_pointcloud.py index 53745f87..b38602d3 100644 --- a/tests/test_pointcloud.py +++ b/tests/test_pointcloud.py @@ -377,5 +377,16 @@ def test_missing_wrapped_object_does_not_recurse(self): # ----------------------------------------------------------------------- # +class TestDispNotebookOptions(unittest.TestCase): + """disp(notebook=True) names an option that Plotly cannot draw""" + + def test_unsupported_option_is_named(self): + pc = PointCloud(np.random.default_rng(0).random((3, 20))) + with self.assertRaises(TypeError) as cm: + pc.disp(notebook=True, point_show_normal=True) + self.assertIn("point_show_normal", str(cm.exception)) + self.assertIn("notebook=True", str(cm.exception)) + + if __name__ == "__main__": unittest.main() From cab0c6515f243e1beae3e400817c12f0e13da5f6 Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Thu, 26 Nov 2026 05:58:07 +1000 Subject: [PATCH 2/4] docs: disp(notebook=True) says which options it accepts PointCloud.disp and VoxelGrid.disp document the TypeError for an option of the Open3D window that Plotly cannot draw, such as point_show_normal. Co-Authored-By: Claude Sonnet 5.5 --- src/machinevisiontoolbox/PointCloud.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/machinevisiontoolbox/PointCloud.py b/src/machinevisiontoolbox/PointCloud.py index a6284e25..9edf2d51 100644 --- a/src/machinevisiontoolbox/PointCloud.py +++ b/src/machinevisiontoolbox/PointCloud.py @@ -508,6 +508,7 @@ def disp( :type notebook: bool, optional :raises ValueError: ``file`` is given with ``notebook=True`` :raises ImportError: ``notebook=True`` and Plotly is not installed + :raises TypeError: ``notebook=True`` and an option that Plotly cannot draw :param front: set front vector :type front: array_like(3) :param lookat: set lookat vector @@ -529,7 +530,9 @@ def disp( ``point_sample_factor`` (the fraction of the points drawn, 0 to 1, which keeps a large cloud responsive) are passed to :func:`open3d.visualization.draw_plotly`. The three axes have the same - scale, so shapes have their true proportions, as in the Open3D window. + scale, so shapes have their true proportions, as in the Open3D window. The + other options of the Open3D window, such as ``point_show_normal``, are not + available with ``notebook=True``, and raise :class:`TypeError`. .. versionchanged:: 2.5.0 Added the ``notebook`` option. @@ -1131,12 +1134,14 @@ def disp( :type notebook: bool, optional :raises ValueError: ``file`` is given with ``notebook=True`` :raises ImportError: ``notebook=True`` and Plotly is not installed + :raises TypeError: ``notebook=True`` and an option that Plotly cannot draw With ``notebook=True`` the voxels are drawn in the output of the notebook cell, as a Plotly figure that can be rotated and zoomed, in the same way as :meth:`PointCloud.disp`, which describes the options, and with the same scale on the three axes. Each voxel is drawn as a cube of 12 triangles, so a - grid of many thousands of voxels is slow. + grid of many thousands of voxels is slow. Options of the Open3D window that + Plotly cannot draw raise :class:`TypeError`. .. versionchanged:: 2.5.0 Added the ``notebook`` option. From 5cb55e9375d9760c19dcc4dd958b5260b31f5380 Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Fri, 27 Nov 2026 06:30:27 +1000 Subject: [PATCH 3/4] docs: PointCloud.disp(notebook=True) points to draw_plotly for its options instead of listing them A list of the accepted options would drift as Open3D changes. The TypeError already lists them from the live signature. Co-Authored-By: Claude Sonnet 5.5 --- src/machinevisiontoolbox/PointCloud.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/machinevisiontoolbox/PointCloud.py b/src/machinevisiontoolbox/PointCloud.py index 9edf2d51..12520577 100644 --- a/src/machinevisiontoolbox/PointCloud.py +++ b/src/machinevisiontoolbox/PointCloud.py @@ -525,14 +525,14 @@ def disp( With ``notebook=True`` the point cloud is drawn in the output of the notebook cell, as a Plotly figure that can be rotated and zoomed. This needs `Plotly `_, which is not installed with the - Toolbox: ``pip install plotly``. ``block`` and ``file`` do not apply, and - besides the view options above, ``width``, ``height`` and - ``point_sample_factor`` (the fraction of the points drawn, 0 to 1, which - keeps a large cloud responsive) are passed to - :func:`open3d.visualization.draw_plotly`. The three axes have the same - scale, so shapes have their true proportions, as in the Open3D window. The - other options of the Open3D window, such as ``point_show_normal``, are not - available with ``notebook=True``, and raise :class:`TypeError`. + Toolbox: ``pip install plotly``. ``block`` and ``file`` do not apply. The + view options above are passed on, along with any other option that + :func:`open3d.visualization.draw_plotly` accepts, such as ``width``, + ``height`` and ``point_sample_factor`` (the fraction of the points drawn, + 0 to 1, which keeps a large cloud responsive). The three axes have the same + scale, so shapes have their true proportions, as in the Open3D window. An + option of the Open3D window that Plotly cannot draw raises + :class:`TypeError`, which names it and lists the options that are accepted. .. versionchanged:: 2.5.0 Added the ``notebook`` option. From a15e52b4cb08711367209ab977b4bb4ee3fccb9c Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Fri, 27 Nov 2026 16:00:24 +1000 Subject: [PATCH 4/4] test: skip the disp(notebook=True) option test without Open3D Co-Authored-By: Claude Sonnet 5.5 --- tests/test_pointcloud.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_pointcloud.py b/tests/test_pointcloud.py index 9b538ab8..235fcfd0 100644 --- a/tests/test_pointcloud.py +++ b/tests/test_pointcloud.py @@ -375,6 +375,7 @@ def test_missing_wrapped_object_does_not_recurse(self): # ----------------------------------------------------------------------- # +@unittest.skipUnless(open3d_available, "open3d not installed") class TestDispNotebookOptions(unittest.TestCase): """disp(notebook=True) names an option that Plotly cannot draw"""