def test_cancel_2d(self): """ Test that the Gaussian division function returns the correct result for two dimensional Gaussians. """ gaussian_a = Gaussian(prec=[[7.0, 2.0], [2.0, 6.0]], h_vec=[4.0, 3.0], g_val=3.0, var_names=["a", "b"]) gaussian_b = Gaussian(prec=[[4.0, 1.0], [1.0, 4.0]], h_vec=[1.0, 2.0], g_val=2.0, var_names=["a", "b"]) expected_quotient = Gaussian(prec=[[3.0, 1.0], [1.0, 2.0]], h_vec=[3.0, 1.0], g_val=1.0, var_names=["a", "b"]) actual_quotient = gaussian_a.divide(gaussian_b) self.assertTrue(expected_quotient.equals(actual_quotient)) gaussian_a_reordered = Gaussian(prec=[[6.0, 2.0], [2.0, 7.0]], h_vec=[3.0, 4.0], g_val=3.0, var_names=["b", "a"]) actual_quotient = gaussian_a_reordered.divide(gaussian_b) actual_quotient._reorder_parameters(["a", "b"]) self.assertTrue(expected_quotient.equals(actual_quotient))
def test_cancel_1d(self): """ Test that the Gaussian division function returns the correct result for one dimensional Gaussians. """ gaussian_a = Gaussian(prec=6.0, h_vec=4.0, g_val=2.0, var_names=["a"]) gaussian_b = Gaussian(prec=3.0, h_vec=2.0, g_val=1.0, var_names=["a"]) expected_quotient = Gaussian(prec=3.0, h_vec=2.0, g_val=1.0, var_names=["a"]) actual_quotient = gaussian_a.divide(gaussian_b) self.assertTrue(expected_quotient.equals(actual_quotient))