Skip to content

fix: PointCloud.normals(radius=..., max_nn=...) still works, with a deprecation warning - #283

Merged
petercorke merged 2 commits into
mainfrom
fix/pointcloud-normals-callable
Nov 27, 2026
Merged

petercorke merged 2 commits into
mainfrom
fix/pointcloud-normals-callable

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Up to MVTB release 0.9, PointCloud.normals(radius=..., max_nn=...) was the method that estimated the normals, and the printed book uses it (chapter 14, §14.7: pcd.normals(radius=0.1, max_nn=30)). In MVTB v1.0.1 (commit 38c4aeb) it became a property that returns the normals, and the method became estimate_normals. These are the names Open3D uses, and the change was part of making the wrapper follow Open3D. The book code has raised TypeError: 'numpy.ndarray' object is not callable since then. The API change stays, and the difference from the printed book is recorded in the RVC3-python errata.

This PR catches the old call. pcd.normals still returns the 3 × N array, as now. Calling it, pcd.normals(radius=0.1, max_nn=30), estimates the normals as before and gives a DeprecationWarning that says to use estimate_normals. The warning is reported at the caller's line, so it shows in a notebook cell.

The array that the property returns is an ndarray subclass. Slices and arithmetic on it are also of that subclass, so they are callable too. np.asarray(normals) gives a plain array.

Tests: the property array, the old call with its warning and the same result as estimate_normals, and normal array behavior. The old-call test fails on the old code. I ran the full suite and mypy, and both are clean.

AI-assisted: written with Claude Code.

🤖 Generated with Claude Code

…eprecation warning

Up to MVTB release 0.9, normals(...) was the method that estimated the normals,
and the printed book uses it (chapter 14).  In MVTB v1.0.1 it became a property
that returns the normals and the method became estimate_normals, which are the
names Open3D uses, so the book code raised TypeError.  The array that the
property returns can now be called, which estimates the normals as before and
warns that estimate_normals is the name to use.  What the property returns is
unchanged.

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

codacy-production Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 13 complexity · 0 duplication

Metric Results
Complexity 13
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.

Both sides added code at the same place in PointCloud.py (the _Normals class here,
_show_in_notebook on main) and in test_pointcloud.py (TestNormals here, the notebook
display tests on main). Both are kept, and the normals docstring uses the new
.. seealso:: style. The full suite passes against this branch's source.
@petercorke
petercorke merged commit 60e13e6 into main Nov 27, 2026
34 checks passed
@petercorke
petercorke deleted the fix/pointcloud-normals-callable branch November 27, 2026 02:13
@github-actions github-actions Bot mentioned this pull request Nov 27, 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.

1 participant