Repository: DistrictDataLabs/yellowbrick

Issue:
JointPlotVisualizer insists on Matplotlib "2.0.0" exactly.
Warns if on mpl.__version__ == "2.0.2". That's overly picky, yes?

Line 133 in features/jointplot.py.


Discussion:

Resolving patch:
diff --git a/yellowbrick/features/jointplot.py b/yellowbrick/features/jointplot.py
--- a/yellowbrick/features/jointplot.py
+++ b/yellowbrick/features/jointplot.py
@@ -129,13 +129,14 @@ def __init__(self, ax=None, feature=None, target=None,
                  xy_plot='hist', xy_args=None,
                  size=6, ratio=5, space=.2, **kwargs):
 
-        #check matplotlib version - needs to be version 2.0.0
-        if mpl.__version__ == "2.0.0":
+        # Check matplotlib version - needs to be version 2.0.0 or greater.
+        mpl_vers_maj = int(mpl.__version__.split(".")[0])
+        if mpl_vers_maj >= 2:
             pass
         else:
             warnings.warn((
-                "{} requires Matplotlib version 2.0.0."
-                "Please upgrade to continue."
+                "{} requires matplotlib major version 2 or greater. "
+                "Please upgrade."
             ).format(self.__class__.__name__))
 
         super(JointPlotVisualizer, self).__init__(ax, **kwargs)


Test patch:
diff --git a/tests/test_features/test_jointplot.py b/tests/test_features/test_jointplot.py
--- a/tests/test_features/test_jointplot.py
+++ b/tests/test_features/test_jointplot.py
@@ -68,12 +68,13 @@ def test_warning(self):
             self.assertEqual(len(w), 1)
             self.assertEqual(
                 str(w[-1].message),
-                "JointPlotVisualizer requires Matplotlib version 2.0.0.Please upgrade to continue."
+                "JointPlotVisualizer requires matplotlib major version 2 "
+                "or greater. Please upgrade."
             )
 
 
     @unittest.skipIf(MPL_VERS_MAJ < 2, "requires matplotlib 2.0.0 or greater")
-    def test_jointplot(self):
+    def test_jointplot_has_no_errors(self):
         """
         Assert no errors occur during jointplot visualizer integration
         """
@@ -84,7 +85,7 @@ def test_jointplot(self):
 
 
     @unittest.skipIf(MPL_VERS_MAJ < 2, "requires matplotlib 2.0.0 or greater")
-    def test_jointplot_integrated(self):
+    def test_jointplot_integrated_has_no_errors(self):
         """
         Test jointplot on the concrete data set
         """
@@ -99,3 +100,27 @@ def test_jointplot_integrated(self):
         visualizer = JointPlotVisualizer(feature=feature, target=target, joint_plot="hex")
         visualizer.fit(X, y)                # Fit the data to the visualizer
         g = visualizer.poof()
+
+
+    @unittest.skipIf(MPL_VERS_MAJ < 2, "requires matplotlib 2.0.0 or greater")
+    def test_jointplot_no_matplotlib2_warning(self):
+        """
+        Assert no UserWarning occurs if matplotlib major version >= 2
+        (and not exactly 2.0.0).
+        """
+        with warnings.catch_warnings(record=True) as ws:
+            # Filter on UserWarnings
+            warnings.filterwarnings("always", category=UserWarning)
+            visualizer = JointPlotVisualizer()
+            visualizer.fit(self.X, self.y)
+            visualizer.poof()
+
+            # Filter out user warnings not related to matplotlib version
+            ver_warn_msg = "requires matplotlib major version 2 or greater"
+            mpl_ver_cnt = 0
+            for w in ws:
+                if w and w.message and ver_warn_msg in str(w.message):
+                    mpl_ver_cnt += 1
+            self.assertEqual(0, mpl_ver_cnt, ws[-1].message \
+                        if ws else "No error")
+