def test_transformation_float(self, x, params): a, b = params transformed_x = (0.5 * np.square(a) * x[:, 2] + b * x[:, 2] + 1) * x[:, 0] transformed_y = (0.5 * np.square(a) * x[:, 2] + b * x[:, 2] + 1) * x[:, 1] transformed_z = x[:, 2] expected = np.stack([transformed_x, transformed_y, transformed_z], axis=1) transformation = TaperingZ() actual = transformation.transform(x, params) self.assertAlmostEqualNumpy(expected, actual)
def test_taylor_approximation(self, x, params): manual_transformation = TaperingRotation() auto_transformation = Composition(TaperingZ(), RotationZ()) expected = taylor.encode(manual_transformation, x, params) actual = taylor.encode(auto_transformation, x, params) self.assertSound(expected, params, partial(manual_transformation.transform, x)) self.assertSound(actual, params, partial(auto_transformation.transform, x)) self.assertAlmostEqualBounds(expected, actual)
def transform(self, points: np.ndarray, params: Union[List[float], List[Interval]]) -> Union[np.ndarray, Interval]: a, b, theta = params return TaperingZ().transform(RotationZ().transform(points, [theta]), [a, b])
def test_transformation_taylor(self, x, params): transformation = TaperingZ() actual = taylor.encode(transformation, x, params) self.assertSound(actual, params, partial(transformation.transform, x))
def test_transformation_interval(self, x, params): transformation = TaperingZ() actual = transformation.transform(x, params) self.assertSound(actual, params, partial(transformation.transform, x))
def test_taylor_twisting_tapering(self, x, params): transformation = Composition(TwistingZ(), TaperingZ()) actual = taylor.encode(transformation, x, params) self.assertSound(actual, params, partial(transformation.transform, x))
def test_hessian_points_params_interval(self, points, params): expected = TaperingRotation().hessian_points_params(points, params) actual = Composition(TaperingZ(), RotationZ()).hessian_points_params( points, params) self.assertAlmostEqualList(expected, actual)
def test_gradient_points_float(self, points, params): expected = TaperingRotation().gradient_points(points, params) actual = Composition(TaperingZ(), RotationZ()).gradient_points(points, params) self.assertAlmostEqualList(expected, actual)
def test_transformation_interval(self, points, params): expected = TaperingRotation().transform(points, params) actual = Composition(TaperingZ(), RotationZ()).transform(points, params) self.assertAlmostEqualInterval(expected, actual)