Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/pyntcloud/structures/voxelgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ def compute(self):
for i in range(3):
# note the +1 in num
s, step = np.linspace(
xyzmin[i], xyzmax[i], num=(self.x_y_z[i] + 1), retstep=True
float(xyzmin[i]),
float(xyzmax[i]),
num=(self.x_y_z[i] + 1),
retstep=True,
dtype=np.float64,
)
segments.append(s)
shape.append(step)
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/structures/test_voxelgrid_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def test_sizes_override_number_of_voxels_per_axis(simple_pyntcloud):
assert np.all(voxelgrid.voxel_n == [0, 0, 31, 62, 124, 124])


def test_query_boundary_points_voxel_assignment(simple_pyntcloud):
voxelgrid = VoxelGrid(points=simple_pyntcloud.xyz, n_x=5, n_y=1, n_z=1)
voxelgrid.compute()
queried = voxelgrid.query(simple_pyntcloud.xyz[[0, 2, 5]])
assert np.all(queried == [0, 1, 4])


@pytest.mark.parametrize(
"x,y,z",
[
Expand Down
Loading