diff --git a/src/pyntcloud/structures/voxelgrid.py b/src/pyntcloud/structures/voxelgrid.py index b35a4df..08b6c4a 100644 --- a/src/pyntcloud/structures/voxelgrid.py +++ b/src/pyntcloud/structures/voxelgrid.py @@ -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) diff --git a/tests/unit/structures/test_voxelgrid_structures.py b/tests/unit/structures/test_voxelgrid_structures.py index c3f02ff..e76c610 100644 --- a/tests/unit/structures/test_voxelgrid_structures.py +++ b/tests/unit/structures/test_voxelgrid_structures.py @@ -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", [