Skip to content

Commit

Permalink
MAINT: add type ignores to sympy and matplotlib imports
Browse files Browse the repository at this point in the history
  • Loading branch information
person142 committed Apr 16, 2020
1 parent 1995688 commit 1927a0e
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 25 deletions.
9 changes: 0 additions & 9 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,9 @@ ignore_missing_imports = True
# Third party dependencies that don't have types.
#

[mypy-matplotlib.*]
ignore_missing_imports = True

[mypy-pytest]
ignore_missing_imports = True

[mypy-sympy]
ignore_missing_imports = True

[mypy-sympy.*]
ignore_missing_imports = True

[mypy-sksparse]
ignore_missing_imports = True

Expand Down
5 changes: 2 additions & 3 deletions scipy/cluster/tests/test_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
# Matplotlib is not a scipy dependency but is optionally used in dendrogram, so
# check if it's available
try:
import matplotlib
import matplotlib # type: ignore[import]
# and set the backend to be Agg (no gui)
matplotlib.use('Agg')
# before importing pyplot
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt # type: ignore[import]
have_matplotlib = True
except Exception:
have_matplotlib = False
Expand Down Expand Up @@ -1055,4 +1055,3 @@ def test_Heap():
pair = heap.get_min()
assert_equal(pair['key'], 1)
assert_equal(pair['value'], 10)

2 changes: 1 addition & 1 deletion scipy/interpolate/interpnd_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
interpolation routines in `interpnd.pyx`.
"""
from sympy import symbols, binomial, Matrix
from sympy import symbols, binomial, Matrix # type: ignore[import]


def _estimate_gradients_2d_global():
Expand Down
2 changes: 1 addition & 1 deletion scipy/optimize/_shgo_lib/triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def plot_complex(self):
To plot a single simplex S in a set C, use e.g., [C[0]]
"""
from matplotlib import pyplot
from matplotlib import pyplot # type: ignore[import]
if self.dim == 2:
pyplot.figure()
for C in self.H:
Expand Down
4 changes: 2 additions & 2 deletions scipy/spatial/_plotutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@_decorator
def _held_figure(func, obj, ax=None, **kw):
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt # type: ignore[import]

if ax is None:
fig = plt.figure()
Expand Down Expand Up @@ -131,7 +131,7 @@ def convex_hull_plot_2d(hull, ax=None):
>>> plt.show()
"""
from matplotlib.collections import LineCollection
from matplotlib.collections import LineCollection # type: ignore[import]

if hull.points.shape[1] != 2:
raise ValueError("Convex hull is not 2-D")
Expand Down
2 changes: 1 addition & 1 deletion scipy/special/_precompute/expn_asy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# https://github.com/sympy/sympy/issues/11255
with suppress_warnings() as sup:
sup.filter(DeprecationWarning, "inspect.getargspec.. is deprecated")
import sympy
import sympy # type: ignore[import]
from sympy import Poly
x = sympy.symbols('x')
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion scipy/special/_precompute/lambertw.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

try:
import mpmath # type: ignore[import]
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt # type: ignore[import]
except ImportError:
pass

Expand Down
2 changes: 1 addition & 1 deletion scipy/special/_precompute/struve_convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt # type: ignore[import]

import mpmath # type: ignore[import]

Expand Down
2 changes: 1 addition & 1 deletion scipy/special/_precompute/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# https://github.com/sympy/sympy/issues/11255
with suppress_warnings() as sup:
sup.filter(DeprecationWarning, "inspect.getargspec.. is deprecated")
from sympy.abc import x
from sympy.abc import x # type: ignore[import]
except ImportError:
pass

Expand Down
2 changes: 1 addition & 1 deletion scipy/special/tests/test_precompute_expn_asy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from scipy.special._precompute.expn_asy import generate_A

try:
import sympy
import sympy # type: ignore[import]
from sympy import Poly
except ImportError:
sympy = MissingModule("sympy")
Expand Down
2 changes: 1 addition & 1 deletion scipy/special/tests/test_precompute_gammainc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from scipy.special._precompute.gammainc_data import gammainc, gammaincc

try:
import sympy
import sympy # type: ignore[import]
except ImportError:
sympy = MissingModule('sympy')

Expand Down
2 changes: 1 addition & 1 deletion scipy/special/tests/test_precompute_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from scipy.special._precompute.utils import lagrange_inversion

try:
import sympy
import sympy # type: ignore[import]
except ImportError:
sympy = MissingModule('sympy')

Expand Down
4 changes: 2 additions & 2 deletions scipy/stats/tests/test_morestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# Matplotlib is not a scipy dependency but is optionally used in probplot, so
# check if it's available
try:
import matplotlib
import matplotlib # type: ignore[import]
matplotlib.rcParams['backend'] = 'Agg'
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt # type: ignore[import]
have_matplotlib = True
except Exception:
have_matplotlib = False
Expand Down

0 comments on commit 1927a0e

Please sign in to comment.