From 59543b7b522aa45938a80d9aa222d196c0d5fba1 Mon Sep 17 00:00:00 2001 From: Nazar Khan Date: Tue, 27 Aug 2024 09:17:01 +0500 Subject: [PATCH 1/2] Fix tests and deprecations, update requirements --- pyntcloud/plot/matplotlib_backend.py | 2 +- pyntcloud/plot/pythreejs_backend.py | 2 +- pyntcloud/plot/pyvista_backend.py | 3 +-- pyntcloud/plot/threejs_backend.py | 2 +- pyntcloud/plot/voxelgrid.py | 2 +- pyntcloud/structures/voxelgrid.py | 4 ++-- requirements.txt | 2 +- tests/__init__.py | 0 tests/data/__init__.py | 0 tests/integration/__init__.py | 0 tests/integration/filters/__init__.py | 0 tests/integration/io/__init__.py | 0 tests/integration/io/test_to_file.py | 2 +- tests/integration/samplers/__init__.py | 0 tests/integration/scalar_fields/__init__.py | 0 tests/integration/structures/__init__.py | 0 tests/unit/__init__.py | 0 tests/unit/filters/__init__.py | 0 tests/unit/ransac/__init__.py | 0 tests/unit/samplers/__init__.py | 0 tests/unit/scalar_fields/__init__.py | 0 tests/unit/structures/__init__.py | 0 22 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/data/__init__.py create mode 100644 tests/integration/__init__.py create mode 100644 tests/integration/filters/__init__.py create mode 100644 tests/integration/io/__init__.py create mode 100644 tests/integration/samplers/__init__.py create mode 100644 tests/integration/scalar_fields/__init__.py create mode 100644 tests/integration/structures/__init__.py create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/filters/__init__.py create mode 100644 tests/unit/ransac/__init__.py create mode 100644 tests/unit/samplers/__init__.py create mode 100644 tests/unit/scalar_fields/__init__.py create mode 100644 tests/unit/structures/__init__.py diff --git a/pyntcloud/plot/matplotlib_backend.py b/pyntcloud/plot/matplotlib_backend.py index a5b24b83..79d446a3 100644 --- a/pyntcloud/plot/matplotlib_backend.py +++ b/pyntcloud/plot/matplotlib_backend.py @@ -22,7 +22,7 @@ def plot_with_matplotlib(cloud, **kwargs): colors = get_colors(cloud, kwargs["use_as_color"], kwargs["cmap"]) - ptp = cloud.xyz.ptp() + ptp = np.ptp(cloud.xyz) plt.figure(figsize=(10, 10)) ax = plt.axes(projection='3d') diff --git a/pyntcloud/plot/pythreejs_backend.py b/pyntcloud/plot/pythreejs_backend.py index 88bb3916..598bf44e 100644 --- a/pyntcloud/plot/pythreejs_backend.py +++ b/pyntcloud/plot/pythreejs_backend.py @@ -69,7 +69,7 @@ def plot_with_pythreejs(cloud, **kwargs): colors = get_colors(cloud, kwargs["use_as_color"], kwargs["cmap"]) - ptp = cloud.xyz.ptp() + ptp = np.ptp(cloud.xyz) children = [] widgets = [] diff --git a/pyntcloud/plot/pyvista_backend.py b/pyntcloud/plot/pyvista_backend.py index 4c811a80..1a6da937 100644 --- a/pyntcloud/plot/pyvista_backend.py +++ b/pyntcloud/plot/pyvista_backend.py @@ -69,7 +69,6 @@ def plot_with_pyvista(cloud, **kwargs): # TODO: Leverage `kwargs["elev"]` and `kwargs["azim"]` - return plotter.show(use_panel=kwargs.pop("use_panel", None), - title=kwargs.pop("title", None), + return plotter.show(title=kwargs.pop("title", None), screenshot=kwargs.pop("screenshot", False), cpos=kwargs.pop("cpos", None) ) diff --git a/pyntcloud/plot/threejs_backend.py b/pyntcloud/plot/threejs_backend.py index 2dd53765..c04875a0 100644 --- a/pyntcloud/plot/threejs_backend.py +++ b/pyntcloud/plot/threejs_backend.py @@ -31,7 +31,7 @@ def plot_with_threejs(cloud, **kwargs): else: mesh = None - ptp = cloud.xyz.ptp() + ptp = np.ptp(cloud.xyz) BASE_PATH = os.path.dirname(os.path.abspath(__file__)) src = "{}/{}".format(BASE_PATH, "points.html") diff --git a/pyntcloud/plot/voxelgrid.py b/pyntcloud/plot/voxelgrid.py index 146866d3..b254216e 100644 --- a/pyntcloud/plot/voxelgrid.py +++ b/pyntcloud/plot/voxelgrid.py @@ -146,7 +146,7 @@ def plot_voxelgrid_with_threejs(voxel_centers, centroid, camera_position = get_centroid_and_camera_position(voxel_centers) if axis: - axis_size = voxel_centers.ptp() * 1.5 + axis_size = np.ptp(voxel_centers) * 1.5 else: axis_size = 0 diff --git a/pyntcloud/structures/voxelgrid.py b/pyntcloud/structures/voxelgrid.py index 3306e3d3..fced5e72 100644 --- a/pyntcloud/structures/voxelgrid.py +++ b/pyntcloud/structures/voxelgrid.py @@ -77,7 +77,7 @@ def compute(self): """ABC API.""" xyzmin = self._points.min(0) xyzmax = self._points.max(0) - xyz_range = self._points.ptp(0) + xyz_range = np.ptp(self._points,0) if self.regular_bounding_box: #: adjust to obtain a minimum bounding box with all sides of equal length @@ -88,7 +88,7 @@ def compute(self): for n, size in enumerate(self.sizes): if size is None: continue - margin = (((self._points.ptp(0)[n] // size) + 1) * size) - self._points.ptp(0)[n] + margin = (((np.ptp(self._points,0)[n] // size) + 1) * size) - np.ptp(self._points,0)[n] xyzmin[n] -= margin / 2 xyzmax[n] += margin / 2 self.x_y_z[n] = ((xyzmax[n] - xyzmin[n]) / size).astype(int) diff --git a/requirements.txt b/requirements.txt index 9e675750..c98642f2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy +numpy<2.0.0 scipy>=1.6.0 pandas laspy diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/data/__init__.py b/tests/data/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/filters/__init__.py b/tests/integration/filters/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/io/__init__.py b/tests/integration/io/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/io/test_to_file.py b/tests/integration/io/test_to_file.py index 9c188790..782ca7b2 100644 --- a/tests/integration/io/test_to_file.py +++ b/tests/integration/io/test_to_file.py @@ -2,7 +2,7 @@ from pyntcloud import PyntCloud -from test_from_file import assert_points_xyz, assert_points_color, assert_mesh +from .test_from_file import assert_points_xyz, assert_points_color, assert_mesh @pytest.mark.parametrize("extension,color,mesh,comments", [ diff --git a/tests/integration/samplers/__init__.py b/tests/integration/samplers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/scalar_fields/__init__.py b/tests/integration/scalar_fields/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/integration/structures/__init__.py b/tests/integration/structures/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/filters/__init__.py b/tests/unit/filters/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/ransac/__init__.py b/tests/unit/ransac/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/samplers/__init__.py b/tests/unit/samplers/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/scalar_fields/__init__.py b/tests/unit/scalar_fields/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/unit/structures/__init__.py b/tests/unit/structures/__init__.py new file mode 100644 index 00000000..e69de29b From 2f88512bc78201f1fd2fc4167b9cbe1070d2aa7c Mon Sep 17 00:00:00 2001 From: Nazar Khan Date: Tue, 27 Aug 2024 11:12:06 +0500 Subject: [PATCH 2/2] Fix numpy imports for threejs backends --- pyntcloud/plot/pythreejs_backend.py | 1 + pyntcloud/plot/threejs_backend.py | 1 + 2 files changed, 2 insertions(+) diff --git a/pyntcloud/plot/pythreejs_backend.py b/pyntcloud/plot/pythreejs_backend.py index 598bf44e..b8b8d1bb 100644 --- a/pyntcloud/plot/pythreejs_backend.py +++ b/pyntcloud/plot/pythreejs_backend.py @@ -12,6 +12,7 @@ display = None from .common import get_colors +import numpy as np def get_pointcloud_pythreejs(xyz, colors): diff --git a/pyntcloud/plot/threejs_backend.py b/pyntcloud/plot/threejs_backend.py index c04875a0..f41530ea 100644 --- a/pyntcloud/plot/threejs_backend.py +++ b/pyntcloud/plot/threejs_backend.py @@ -5,6 +5,7 @@ from pathlib import Path import pandas as pd +import numpy as np try: from IPython.display import IFrame