Skip to content

Commit

Permalink
Repair broken tests with matplotlib 3.3 (#1090)
Browse files Browse the repository at this point in the history
This PR repairs visual tests and replaces images that caused failures after MPL version 3.3. It also removes Miniconda from Appveyor test matrix because it was causing the tests to hang indefinitely.

Co-authored-by: Benjamin Bengfort <benjamin@bengfort.com>
  • Loading branch information
rebeccabilbro and bbengfort committed Aug 6, 2020
1 parent bc693dc commit b58988e
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 13 deletions.
11 changes: 6 additions & 5 deletions .appveyor.yml
Expand Up @@ -4,7 +4,7 @@
image:
- Previous Visual Studio 2017

version: 0.9.{build}
version: 1.1.{build}
pull_requests:
do_not_increment_build_number: true

Expand Down Expand Up @@ -36,10 +36,11 @@ environment:
PYTHON_VERSION: "3.7"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Miniconda36-x64"
PYTHON_VERSION: "3.6"
MINICONDA_VERSION: "4.8.2"
PYTHON_ARCH: "64"
# Tests hang indefinitely
# - PYTHON: "C:\\Miniconda36-x64"
# PYTHON_VERSION: "3.6"
# MINICONDA_VERSION: "4.8.2"
# PYTHON_ARCH: "64"

# Failing Tests Due to TypeError: LoadLibrary()
# - PYTHON: "C:\\Miniconda37-x64"
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/baseline_images/test_draw/test_manual_legend.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/baseline_images/test_features/test_pca/test_biplot_3d.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/requirements.txt
@@ -1,5 +1,5 @@
# Library Dependencies
matplotlib>=3.2.1
matplotlib>=3.3
scipy>=1.0.0
scikit-learn>=0.20
numpy>=1.13.0
Expand Down
9 changes: 6 additions & 3 deletions tests/test_features/test_jointplot.py
Expand Up @@ -408,7 +408,8 @@ def test_columns_single_int_index_numpy_hist(self):
assert hasattr(oz, "corr_")

oz.finalize()
self.assert_images_similar(oz)
# Python 3.6 Travis ImageComparisonFailure: images not close (RMS 0.837)
self.assert_images_similar(oz, tol=1.0)

@pytest.mark.skipif(pd is None, reason="test requires pandas")
@pytest.mark.xfail(
Expand All @@ -426,7 +427,8 @@ def test_columns_single_str_index_pandas_hist(self):
assert hasattr(oz, "corr_")

oz.finalize()
self.assert_images_similar(oz)
# Python 3.6 Travis ImageComparisonFailure: images not close (RMS 1.109)
self.assert_images_similar(oz, tol=1.5)

@pytest.mark.xfail(
IS_WINDOWS_OR_CONDA,
Expand Down Expand Up @@ -505,4 +507,5 @@ def test_quick_method(self):
assert isinstance(oz, JointPlot)
assert hasattr(oz, "corr_")

self.assert_images_similar(oz)
# Python 3.6 Travis ImageComparisonFailure: images not close (RMS 0.837)
self.assert_images_similar(oz, tol=1.0)
3 changes: 2 additions & 1 deletion tests/test_features/test_rankd.py
Expand Up @@ -358,7 +358,8 @@ def test_rank2d_pearson(self):

# Image similarity comparision
oz.finalize()
self.assert_images_similar(oz, tol=0.1)
# Travis Python 3.6 images not close (RMS 0.112)
self.assert_images_similar(oz, tol=0.5)

@pytest.mark.xfail(
IS_WINDOWS_OR_CONDA,
Expand Down
6 changes: 4 additions & 2 deletions tests/test_meta.py
Expand Up @@ -152,11 +152,13 @@ def test_random_visualizer_not_close(self):
"""
Test that not close visualizers raise an assertion error.
"""
# Baseline image random_state=225
viz = RandomVisualizer(random_state=224).fit()
# Baseline image random_state=224
# NOTE: if regenerating baseline images, skip this one or change random state!
viz = RandomVisualizer(random_state=225).fit()
viz.finalize()

with pytest.raises(ImageComparisonFailure, match="images not close"):
# If failing, perhaps baseline images were regenerated? See note above.
self.assert_images_similar(viz)

# Assert there is a diff
Expand Down
Binary file added tests/test_random_visualizer_not_close.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion tests/test_regressor/test_alphas.py
Expand Up @@ -217,4 +217,5 @@ def test_quick_method_manual(self):
ElasticNet(random_state=0), X, y, cv=3, is_fitted=False, show=False
)
assert isinstance(visualizer, ManualAlphaSelection)
self.assert_images_similar(visualizer)
# Python 3.6 Travis images not similar (RMS 0.024)
self.assert_images_similar(visualizer, tol=0.5)
16 changes: 16 additions & 0 deletions tests/test_style/test_rcmod.py
Expand Up @@ -41,6 +41,22 @@ class RCParamTester(VisualTestCase):
"backend", # This cannot be changed by manipulating rc
"svg.embed_char_paths", # This param causes test issues and is deprecated
"font.family", # breaks the visualtest case

# The following are not able to be set by a style in matplotlib 2.0
# See: https://bit.ly/39UWTCY
"interactive",
"backend.qt4",
"webagg.port",
"webagg.port_retries",
"webagg.open_in_browser",
"backend_fallback",
"toolbar",
"timezone",
"datapath",
"figure.max_open_warning",
"savefig.directory",
"tk.window_focus",
"docstring.hardcopy",
}

def flatten_list(self, orig_list):
Expand Down

0 comments on commit b58988e

Please sign in to comment.