

def copy(self):
    "\n        Returns a copy of JunctionTree.\n\n        Returns\n        -------\n        JunctionTree : copy of JunctionTree\n\n        Examples\n        -------\n        >>> import numpy as np\n        >>> from pgmpy.factors import Factor\n        >>> from pgmpy.models import JunctionTree\n        >>> G = JunctionTree()\n        >>> G.add_edges_from([(('a', 'b', 'c'), ('a', 'b')), (('a', 'b', 'c'), ('a', 'c'))])\n        >>> phi1 = Factor(['a', 'b'], [1, 2], np.random.rand(2))\n        >>> phi2 = Factor(['a', 'c'], [1, 2], np.random.rand(2))\n        >>> G.add_factors(phi1,phi2)\n        >>> modelCopy = G.copy()\n        >>> modelCopy.edges()\n        [(('a', 'b'), ('a', 'b', 'c')), (('a', 'c'), ('a', 'b', 'c'))]\n        >>> G.factors\n        [<Factor representing phi(a:1, b:2) at 0xb720ee4c>, <Factor representing phi(a:1, c:2) at 0xb4e1e06c>]\n        >>> modelCopy.factors\n        [<Factor representing phi(a:1, b:2) at 0xb4bd11ec>, <Factor representing phi(a:1, c:2) at 0xb4bd138c>]\n\n        "
    copy = JunctionTree(copy.edges())
    copy.add_nodes_from(self.nodes())
    if self.factors:
        factors_copy = [factor.copy() for factor in self.factors]
        copy.add_factors(*factors_copy)
    return copy

dataset/ETHPy150Open pgmpy/pgmpy/pgmpy/models/JunctionTree.py JunctionTree.copy/VarMisuse@16/466 `self`->`copy`