Esempio n. 1
0
    def test_points_equal(self):
        points1 = {1: gp.Point([0, 1])}
        points2 = {1: gp.Point([0, 1])}
        self.assertTrue(self.points_equal(points1, points2))

        points1[2] = gp.Point([1, 2])
        points2[2] = gp.Point([2, 1])
        self.assertFalse(self.points_equal(points1, points2))
Esempio n. 2
0
    def test_shift_points5(self):
        data = {
            0: gp.Point([3, 0]),
            1: gp.Point([3, 2]),
            2: gp.Point([3, 4]),
            3: gp.Point([3, 6]),
            4: gp.Point([3, 8])
        }
        spec = gp.PointsSpec(gp.Roi(offset=(0, 0), shape=(15, 10)))
        points = gp.Points(data, spec)
        request_roi = gp.Roi(offset=(3, 0), shape=(9, 10))
        shift_array = np.array([[3, 0], [-3, 0], [0, 0], [-3, 0], [3, 0]],
                               dtype=int)

        lcm_voxel_size = gp.Coordinate((3, 2))
        shifted_data = {
            0: gp.Point([6, 0]),
            2: gp.Point([3, 4]),
            4: gp.Point([6, 8])
        }
        result = gp.ShiftAugment.shift_points(points,
                                              request_roi,
                                              shift_array,
                                              shift_axis=1,
                                              lcm_voxel_size=lcm_voxel_size)
        # print("test 4", result.data, shifted_data)
        self.assertTrue(self.points_equal(result.data, shifted_data))
        self.assertTrue(result.spec == gp.PointsSpec(request_roi))
Esempio n. 3
0
    def test_shift_points3(self):
        data = {1: gp.Point([0, 1])}
        spec = gp.PointsSpec(gp.Roi(offset=(0, 0), shape=(5, 5)))
        points = gp.Points(data, spec)
        request_roi = gp.Roi(offset=(0, 1), shape=(5, 3))
        shift_array = np.array([[0, 1], [0, -1], [0, 0], [0, 0], [0, 1]],
                               dtype=int)
        lcm_voxel_size = gp.Coordinate((1, 1))

        shifted_points = gp.Points({1: gp.Point([0, 2])},
                                   gp.PointsSpec(request_roi))
        result = gp.ShiftAugment.shift_points(points,
                                              request_roi,
                                              shift_array,
                                              shift_axis=0,
                                              lcm_voxel_size=lcm_voxel_size)
        # print("test 3", result.data, shifted_points.data)
        self.assertTrue(self.points_equal(result.data, shifted_points.data))
        self.assertTrue(result.spec == gp.PointsSpec(request_roi))