code: def test_marginalize(self):
      phi = self.phi1.marginalize(["x1"], inplace=False)
      self.assertEqual(phi.variables, ["x2", "x3"])
      np_test.assert_almost_equal(
          phi.K, np.array([[3.090909, -2.0], [-2.0, 4.0]])
      )
      np_test.assert_almost_equal(
          phi.h, np.array([[5.6090909], [-1.0]])
      )
      np_test.assert_almost_equal(phi.g, -0.5787165566)
  
      phi = self.phi1.marginalize(["x1", "x2"], inplace=False)
      self.assertEqual(phi.variables, ["x3"])
      np_test.assert_almost_equal(phi.K, np.array([[2.70588235]]))
      np_test.assert_almost_equal(phi.h, np.array([[2.62941176]]))
      np_test.assert_almost_equal(phi.g, 39.25598935059)
  
      self.phi1.marginalize(["x1"])
      self.assertEqual(self.phi1.variables, ["x2", "x3"])
      np_test.assert_almost_equal(
          self.phi1.K, np.array([[3.090909, -2.0], [-2.0, 4.0]])
      )
      np_test.assert_almost_equal(
          self.phi1.h, np.array([[5.6090909], [-1.0]])
      )
      np_test.assert_almost_equal(self.phi1.g, -0.5787165566)
  
      self.phi1 = self.phi3
      self.phi1.marginalize(["x1", "x2"])
      self.assertEqual(self.phi1.variables, ["x3"])
      np_test.assert_almost_equal(self.phi1.K, np.array([[2.70588235]]))
      np_test.assert_almost_equal(self.phi1.h, np.array([[2.62941176]]))
      np_test.assert_almost_equal(self.phi1.g, 39.25598935059)
  
      self.phi1 = self.phi3
  
file_path: pgmpy/pgmpy/tests/test_factors/test_continuous/test_Canonical_Factor.py
imports: import unittest
  import numpy
  import numpy.testing
  from pgmpy.factors.distributions import GaussianDistribution
  from pgmpy.factors.continuous import CanonicalDistribution
label_desc: Use image node_id 5 for calling the TestJGDMethods obj's underlying member method code with example usage: obj.test_marginalize() without return types