Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36b554f

Browse files
authored
Merge pull request #11522 from anntzer/cleanups
Small cleanups.
2 parents dcbf144 + 168990b commit 36b554f

File tree

5 files changed

+19
-30
lines changed

5 files changed

+19
-30
lines changed

doc/api/next_api_changes/2018-02-26-AL-removals.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ The following deprecated API elements have been removed:
3636
- passing non-numbers to ``EngFormatter.format_eng``,
3737
- passing ``frac`` to ``PolarAxes.set_theta_grids``,
3838
- any mention of idle events,
39+
40+
The following API elements have been removed:
41+
42+
- ``matplotlib.sphinxext.sphinx_version``,

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,6 @@
153153
align = Image.align
154154
import sphinx
155155

156-
sphinx_version = sphinx.__version__.split(".")
157-
# The split is necessary for sphinx beta versions where the string is
158-
# '6b1'
159-
sphinx_version = tuple([int(re.split('[^0-9]', x)[0])
160-
for x in sphinx_version[:2]])
161-
162156
import jinja2 # Sphinx dependency.
163157

164158
import matplotlib

lib/matplotlib/testing/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import functools
2+
import locale
23
import warnings
34

45
import matplotlib as mpl
@@ -24,8 +25,6 @@ def set_reproducibility_for_testing():
2425
def setup():
2526
# The baseline images are created in this locale, so we should use
2627
# it during all of the tests.
27-
import locale
28-
from matplotlib.backends import backend_agg, backend_pdf, backend_svg
2928

3029
try:
3130
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
@@ -35,15 +34,15 @@ def setup():
3534
except locale.Error:
3635
warnings.warn(
3736
"Could not set locale to English/United States. "
38-
"Some date-related tests may fail")
37+
"Some date-related tests may fail.")
3938

4039
mpl.use('Agg', warn=False) # use Agg backend for these tests
4140

42-
# These settings *must* be hardcoded for running the comparison tests and
43-
# are not necessarily the default values as specified in rcsetup.py
4441
with warnings.catch_warnings():
4542
warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
4643
mpl.rcdefaults() # Start with all defaults
4744

45+
# These settings *must* be hardcoded for running the comparison tests and
46+
# are not necessarily the default values as specified in rcsetup.py.
4847
set_font_settings_for_testing()
4948
set_reproducibility_for_testing()

lib/matplotlib/tests/test_rcparams.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from collections import OrderedDict
2+
import copy
3+
from itertools import chain
4+
import locale
25
import os
36
from unittest import mock
47
import warnings
@@ -9,7 +12,6 @@
912
import matplotlib as mpl
1013
import matplotlib.pyplot as plt
1114
import matplotlib.colors as mcolors
12-
from itertools import chain
1315
import numpy as np
1416
from matplotlib.rcsetup import (validate_bool_maybe_none,
1517
validate_stringlist,
@@ -25,15 +27,13 @@
2527
_validate_linestyle)
2628

2729

28-
mpl.rc('text', usetex=False)
29-
mpl.rc('lines', linewidth=22)
30-
31-
fname = os.path.join(os.path.dirname(__file__), 'test_rcparams.rc')
32-
33-
3430
def test_rcparams():
31+
mpl.rc('text', usetex=False)
32+
mpl.rc('lines', linewidth=22)
33+
3534
usetex = mpl.rcParams['text.usetex']
3635
linewidth = mpl.rcParams['lines.linewidth']
36+
fname = os.path.join(os.path.dirname(__file__), 'test_rcparams.rc')
3737

3838
# test context given dictionary
3939
with mpl.rc_context(rc={'text.usetex': not usetex}):
@@ -51,11 +51,8 @@ def test_rcparams():
5151
assert mpl.rcParams['lines.linewidth'] == linewidth
5252

5353
# test rc_file
54-
try:
55-
mpl.rc_file(fname)
56-
assert mpl.rcParams['lines.linewidth'] == 33
57-
finally:
58-
mpl.rcParams['lines.linewidth'] = linewidth
54+
mpl.rc_file(fname)
55+
assert mpl.rcParams['lines.linewidth'] == 33
5956

6057

6158
def test_RcParams_class():
@@ -131,8 +128,7 @@ def test_Bug_2543():
131128
mpl.rcParams[key] = _copy[key]
132129
mpl.rcParams['text.dvipnghack'] = None
133130
with mpl.rc_context():
134-
from copy import deepcopy
135-
_deep_copy = deepcopy(mpl.rcParams)
131+
_deep_copy = copy.deepcopy(mpl.rcParams)
136132
# real test is that this does not raise
137133
assert validate_bool_maybe_none(None) is None
138134
assert validate_bool_maybe_none("none") is None
@@ -194,7 +190,6 @@ def test_mec_rcparams():
194190
def test_Issue_1713():
195191
utf32_be = os.path.join(os.path.dirname(__file__),
196192
'test_utf32_be_rcparams.rc')
197-
import locale
198193
with mock.patch('locale.getpreferredencoding', return_value='UTF-32-BE'):
199194
rc = mpl.rc_params_from_file(utf32_be, True, False)
200195
assert rc.get('timezone') == 'UTC'

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,8 @@ def run(self):
241241
for mod in ext_modules:
242242
mod.finalize()
243243

244-
extra_args = {}
245-
246244
# Finally, pass this all along to distutils to do the heavy lifting.
247-
distrib = setup(
245+
setup(
248246
name="matplotlib",
249247
version=__version__,
250248
description="Python plotting package",
@@ -278,5 +276,4 @@ def run(self):
278276
# check for zip safety.
279277
zip_safe=False,
280278
cmdclass=cmdclass,
281-
**extra_args
282279
)

0 commit comments

Comments
 (0)