Beispiel #1
0
    def with_dims(self, dims):
        r"""
        Return a copy of this shape with only particular dimensions retained.

        Parameters
        ----------
        dims : valid numpy array slice
            The slice that will be used on the dimensionality axis of the shape
            under transform. For example, to go from a 3D shape to a 2D one,
            [0, 1] could be provided or np.array([True, True, False]).

        Returns
        -------
        copy of self, with only the requested dims
        """
        return WithDims(dims).apply(self)
Beispiel #2
0
def test_withdims_transform():
    pc_3d = PointCloud(np.random.random((14, 3)))
    pc_2d = WithDims([0, 1]).apply(pc_3d)
    assert np.all(pc_3d.points[:, :2] == pc_2d.points)
Beispiel #3
0
def test_withdims_single_axis_transform():
    pc_3d = PointCloud(np.random.random((14, 3)))
    pc_1d = WithDims(0).apply(pc_3d)
    assert np.all(pc_3d.points[:, :0] == pc_1d.points)
    assert pc_1d.n_dims == 1
    assert pc_1d.n_points == pc_3d.n_points