From a3134fcfed616124a4f22b7319b13159aa9b77e4 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Sun, 23 Aug 2020 09:01:36 -0700 Subject: [PATCH] take the linter's advice --- check_probscale.py | 8 +------- probscale/tests/__init__.py | 2 +- probscale/tests/test_formatters.py | 1 - probscale/tests/test_probscale.py | 5 ++--- probscale/tests/test_validate.py | 2 +- probscale/tests/test_viz.py | 9 +++------ probscale/viz.py | 1 - setup.py | 2 -- 8 files changed, 8 insertions(+), 22 deletions(-) diff --git a/check_probscale.py b/check_probscale.py index 762e924..ed5bf39 100644 --- a/check_probscale.py +++ b/check_probscale.py @@ -1,13 +1,7 @@ import sys -import matplotlib - -matplotlib.use("agg") - -from matplotlib.pyplot import style - -style.use("classic") from probscale import tests + status = tests.test(*sys.argv[1:]) sys.exit(status) diff --git a/probscale/tests/__init__.py b/probscale/tests/__init__.py index 5e06827..5af448d 100644 --- a/probscale/tests/__init__.py +++ b/probscale/tests/__init__.py @@ -6,7 +6,7 @@ def test(*args): try: import pytest - except ImportError as e: + except ImportError: raise ImportError("`pytest` is required to run the test suite") options = [resource_filename("probscale", "tests")] diff --git a/probscale/tests/test_formatters.py b/probscale/tests/test_formatters.py index 04bdfb8..afb71f1 100644 --- a/probscale/tests/test_formatters.py +++ b/probscale/tests/test_formatters.py @@ -1,7 +1,6 @@ import numpy import pytest -import numpy.testing as nptest from probscale import formatters diff --git a/probscale/tests/test_probscale.py b/probscale/tests/test_probscale.py index 351ef08..2fa4693 100644 --- a/probscale/tests/test_probscale.py +++ b/probscale/tests/test_probscale.py @@ -1,12 +1,11 @@ import os -import sys import numpy import matplotlib.pyplot as plt try: from scipy import stats -except: # pragma: no cover +except ImportError: # pragma: no cover stats = None import pytest @@ -127,7 +126,7 @@ def test_sign_with_nan_no_warning(mn): assert numpy.isnan(res) -def test_sign_with_nan_no_warning(mn): +def test_sign_with_nan_no_warning_inv(mn): with pytest.warns(None) as record: res = mn._approx_inv_erf(numpy.nan) assert not record diff --git a/probscale/tests/test_validate.py b/probscale/tests/test_validate.py index faec196..a2fd184 100644 --- a/probscale/tests/test_validate.py +++ b/probscale/tests/test_validate.py @@ -43,7 +43,7 @@ def test_fit_arguments_valid(which, kwarg): assert result == which -@pytest.mark.parametrize(("kwarg",), [("fitprobs",), ("fitlogs",),]) +@pytest.mark.parametrize("kwarg", ["fitprobs", "fitlogs"]) def test_fit_arguments_invalid(kwarg): with pytest.raises(ValueError): validate.fit_argument("junk", kwarg) diff --git a/probscale/tests/test_viz.py b/probscale/tests/test_viz.py index 27af488..ed79aee 100644 --- a/probscale/tests/test_viz.py +++ b/probscale/tests/test_viz.py @@ -1,18 +1,15 @@ -import sys -from functools import wraps - import numpy import matplotlib.lines import matplotlib.pyplot as plt try: from scipy import stats -except: # pragma: no cover +except ImportError: # pragma: no cover stats = None try: import seaborn -except: # pragma: no cover +except ImportError: # pragma: no cover seaborn = None from probscale import viz @@ -1075,6 +1072,6 @@ def test_probplot_with_FacetGrid_with_markers(usemarkers): _lines = filter( lambda x: isinstance(x, matplotlib.lines.Line2D), fg.ax.get_children() ) - result_markers = {l.get_label(): l.get_marker() for l in _lines} + result_markers = {line.get_label(): line.get_marker() for line in _lines} expected_markers = dict(zip(species, markers)) assert expected_markers == result_markers diff --git a/probscale/viz.py b/probscale/viz.py index bcbd5f8..af4ff56 100644 --- a/probscale/viz.py +++ b/probscale/viz.py @@ -1,7 +1,6 @@ import copy import numpy -from matplotlib import pyplot from .probscale import _minimal_norm from . import validate diff --git a/setup.py b/setup.py index f8d1269..792118a 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,6 @@ # # Usage: python setup.py install - -import os from setuptools import setup, find_packages