Repository: top-tier-ci-coders/pgmpy

Issue:
Move `BayesianModel.get_markov_blanket` method

Discussion:

Patch:
diff --git a/.travis.yml b/.travis.yml
index f10b836..bc27d17 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,10 +2,7 @@
         virtualenv:
             system_site_packages: false
         env:
-            - DISTRIB="conda" PYTHON_VERSION="3.4" COVERAGE="true"
             - DISTRIB="conda" PYTHON_VERSION="3.5" COVERAGE="true"
-            - DISTRIB="conda" PYTHON_VERSION="3.6" COVERAGE="true"
-            - DISTRIB="conda" PYTHON_VERSION="3.7" COVERAGE="true"
 
         before_install:
             - uname -a
diff --git a/pgmpy/base/DAG.py b/pgmpy/base/DAG.py
index f2ade04..50cdb9f 100644
--- a/pgmpy/base/DAG.py
+++ b/pgmpy/base/DAG.py
@@ -385,20 +385,15 @@ class DAG(nx.DiGraph):
     def is_active_trail(self, start, end, observed=None):
         """
         Returns True if there is any active trail between start and end node
-
         Parameters
         ----------
         start : Graph Node
-
         end : Graph Node
-
         observed : List of nodes (optional)
             If given the active trail would be computed assuming these nodes to be observed.
-
         additional_observed : List of nodes (optional)
             If given the active trail would be computed assuming these nodes to be observed along with
             the nodes marked as observed in the model.
-
         Examples
         --------
         >>> from pgmpy.base import DAG
@@ -415,3 +410,36 @@ class DAG(nx.DiGraph):
             return True
         else:
             return False
+
+    def get_markov_blanket(self, node):
+        """
+        Returns a markov blanket for a random variable. In the case
+        of Bayesian Networks, the markov blanket is the set of
+        node's parents, its children and its children's other parents.
+
+        Returns
+        -------
+        list(blanket_nodes): List of nodes contained in Markov Blanket
+
+        Parameters
+        ----------
+        node: string, int or any hashable python object.
+              The node whose markov blanket would be returned.
+
+        Examples
+        --------
+        >>> from pgmpy.base import DAG
+        >>> from pgmpy.factors.discrete import TabularCPD
+        >>> G = DAG([('x', 'y'), ('z', 'y'), ('y', 'w'), ('y', 'v'), ('u', 'w'),
+                               ('s', 'v'), ('w', 't'), ('w', 'm'), ('v', 'n'), ('v', 'q')])
+        >>> G.get_markov_blanket('y')
+        ['s', 'w', 'x', 'u', 'z', 'v']
+        """
+        children = self.get_children(node)
+        parents = self.get_parents(node)
+        blanket_nodes = children + parents
+        for child_node in children:
+            blanket_nodes.extend(self.get_parents(child_node))
+        blanket_nodes = set(blanket_nodes)
+        blanket_nodes.remove(node)
+        return list(blanket_nodes)
diff --git a/pgmpy/models/BayesianModel.py b/pgmpy/models/BayesianModel.py
index a7a7887..22a3e44 100644
--- a/pgmpy/models/BayesianModel.py
+++ b/pgmpy/models/BayesianModel.py
@@ -938,36 +938,3 @@ class BayesianModel(DAG):
         if self.cpds:
             model_copy.add_cpds(*[cpd.copy() for cpd in self.cpds])
         return model_copy
-
-    def get_markov_blanket(self, node):
-        """                                                       
-        Returns a markov blanket for a random variable. In the case
-        of Bayesian Networks, the markov blanket is the set of 
-        node's parents, its children and its children's other parents. 
-        
-        Returns
-        -------
-        list(blanket_nodes): List of nodes contained in Markov Blanket
-
-        Parameters
-        ----------
-        node: string, int or any hashable python object.
-              The node whose markov blanket would be returned.
-                                                                  
-        Examples                                                  
-        --------                                                  
-        >>> from pgmpy.models import BayesianModel
-        >>> from pgmpy.factors.discrete import TabularCPD
-        >>> G = BayesianModel([('x', 'y'), ('z', 'y'), ('y', 'w'), ('y', 'v'), ('u', 'w'), 
-                               ('s', 'v'), ('w', 't'), ('w', 'm'), ('v', 'n'), ('v', 'q')])
-        >>> bayes_model.get_markov_blanket('y') 
-        ['s', 'w', 'x', 'u', 'z', 'v']
-        """
-        children = self.get_children(node)
-        parents = self.get_parents(node)
-        blanket_nodes = children + parents
-        for child_node in children:
-            blanket_nodes.extend(self.get_parents(child_node))
-        blanket_nodes = set(blanket_nodes)
-        blanket_nodes.remove(node)
-        return list(blanket_nodes)


Test patch:
diff --git a/pgmpy/tests/test_models/test_BayesianModel.py b/pgmpy/tests/test_models/test_BayesianModel.py
index 2c7ecf0..be8d9c4 100644
--- a/pgmpy/tests/test_models/test_BayesianModel.py
+++ b/pgmpy/tests/test_models/test_BayesianModel.py
@@ -6,6 +6,7 @@ import numpy as np
 import numpy.testing as np_test
 
 from pgmpy.models import BayesianModel, MarkovModel
+from pgmpy.base import DAG
 import pgmpy.tests.help_functions as hf
 from pgmpy.factors.discrete import TabularCPD, JointProbabilityDistribution, DiscreteFactor
 from pgmpy.independencies import Independencies
@@ -177,7 +178,7 @@ class TestBayesianModelMethods(unittest.TestCase):
         self.assertRaises(TypeError, self.G1.is_imap, fac)
 
     def test_markov_blanet(self):
-        G = BayesianModel([('x', 'y'), ('z', 'y'), ('y', 'w'), ('y', 'v'), ('u', 'w'),
+        G = DAG([('x', 'y'), ('z', 'y'), ('y', 'w'), ('y', 'v'), ('u', 'w'),
                            ('s', 'v'), ('w', 't'), ('w', 'm'), ('v', 'n'), ('v', 'q')])
         self.assertEqual(set(G.get_markov_blanket('y')), set(['s', 'w', 'x', 'u', 'z', 'v']))