Skip to content

Commit 3add1a6

Browse files
authored
PyVista: point_arrays -> point_data (#327)
1 parent f07a236 commit 3add1a6

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

pyntcloud/io/pyvista.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def from_pyvista(poly_data, **kwargs):
2424

2525
points = pd.DataFrame(data=poly_data.points, columns=["x", "y", "z"])
2626

27-
scalars = poly_data.point_arrays
27+
scalars = poly_data.point_data
2828
for name, array in scalars.items():
2929
if array.ndim == 1:
3030
points[name] = array
@@ -72,11 +72,11 @@ def to_pyvista(cloud, mesh=False, use_as_color=("red", "green", "blue"), **kwarg
7272
# add scalar arrays
7373
if all(c in cloud.points.columns for c in use_as_color):
7474
colors = cloud.points[list(use_as_color)].values
75-
poly.point_arrays["RGB"] = colors
75+
poly.point_data["RGB"] = colors
7676
avoid += list(use_as_color)
7777
# Add other arrays
7878
for name in cloud.points.columns:
7979
if name not in avoid:
80-
poly.point_arrays[name] = cloud.points[name]
80+
poly.point_data[name] = cloud.points[name]
8181

8282
return poly

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ ipython
77
matplotlib
88
numba
99
pytest
10-
pyvista
10+
pyvista>=0.32.0
1111
open3d

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
],
2626
extras_require={
2727
'LAS': ["pylas", "lazrs"],
28-
'PLOT': ["ipython", "matplotlib", "pyvista"],
28+
'PLOT': ["ipython", "matplotlib", "pyvista>=0.32.0"],
2929
'NUMBA': ["numba"]
3030
},
3131
classifiers=[

tests/integration/io/test_from_instance.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def test_pyvista_conversion(data_path):
2323
cloud = PyntCloud.from_instance("pyvista", original_point_cloud)
2424
assert np.allclose(cloud.xyz, original_point_cloud.points)
2525
assert {'red', 'green', 'blue'}.issubset(cloud.points.columns)
26-
assert np.allclose(cloud.points[['red', 'green', 'blue']].values, original_point_cloud.point_arrays["RGB"])
26+
assert np.allclose(cloud.points[['red', 'green', 'blue']].values, original_point_cloud.point_data["RGB"])
2727
assert {'nx', 'ny', 'nz'}.issubset(cloud.points.columns)
28-
assert np.allclose(cloud.points[['nx', 'ny', 'nz']].values, original_point_cloud.point_arrays["Normals"])
28+
assert np.allclose(cloud.points[['nx', 'ny', 'nz']].values, original_point_cloud.point_data["Normals"])
2929
assert cloud.mesh is not None
3030

3131

@@ -39,7 +39,7 @@ def test_pyvista_normals_are_handled():
3939
@pytest.mark.skipif(SKIP_PYVISTA, reason="Requires PyVista")
4040
def test_pyvista_multicomponent_scalars_are_splitted():
4141
poly = pv.Sphere()
42-
poly.point_arrays["foo"] = np.zeros_like(poly.points)
42+
poly.point_data["foo"] = np.zeros_like(poly.points)
4343
pc = PyntCloud.from_instance("pyvista", poly)
4444
assert all(x in pc.points.columns for x in ["foo_0", "foo_1", "foo_2"])
4545

@@ -50,7 +50,7 @@ def test_pyvista_rgb_is_handled():
5050
if poin_arrays contain a field with `name in "RGB"`
5151
"""
5252
poly = pv.Sphere()
53-
poly.point_arrays["RG"] = np.zeros_like(poly.points)[:, :2]
53+
poly.point_data["RG"] = np.zeros_like(poly.points)[:, :2]
5454
pc = PyntCloud.from_instance("pyvista", poly)
5555
assert all(x in pc.points.columns for x in ["RG_0", "RG_1"])
5656

0 commit comments

Comments
 (0)