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

Skip to content

Commit b03b71a

Browse files
committed
MAINT created a new private _classic_test stylesheet
This allows the public classic stylesheet to be 'more' backward compatible
1 parent e274ed9 commit b03b71a

File tree

7 files changed

+561
-38
lines changed

7 files changed

+561
-38
lines changed

doc/users/dflt_style_changes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ values is a single line of python
1515
1616
mpl.style.use('classic')
1717
18-
Note that to revert the position of tick labels, you need in addition to set
19-
the rcParams `ytick.alignment` to "center".
20-
2118
See :ref:`customizing-with-matplotlibrc-files` for details about how to
2219
persistently and selectively revert many of these changes.
2320

lib/matplotlib/mpl-data/stylelib/_classic_test.mplstyle

Lines changed: 526 additions & 0 deletions
Large diffs are not rendered by default.

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ ytick.major.left : True # draw y axis left major ticks
271271
ytick.major.right : True # draw y axis right major ticks
272272
ytick.minor.left : True # draw y axis left minor ticks
273273
ytick.minor.right : True # draw y axis right minor ticks
274+
ytick.alignment : center
274275

275276
### GRIDS
276277
grid.color : k # grid color

lib/matplotlib/testing/decorators.py

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import warnings
1313
import unittest
1414

15-
# Note - don't import nose up here - import it only as needed in functions. This
16-
# allows other functions here to be used by pytest-based testing suites without
17-
# requiring nose to be installed.
15+
# Note - don't import nose up here - import it only as needed in functions.
16+
# This allows other functions here to be used by pytest-based testing suites
17+
# without requiring nose to be installed.
1818

1919
import numpy as np
2020

@@ -163,7 +163,7 @@ def wrapped_callable(*args, **kwargs):
163163
return make_cleanup
164164
else:
165165
result = make_cleanup(style)
166-
style = 'classic'
166+
style = '_classic_test'
167167
return result
168168

169169

@@ -268,43 +268,42 @@ def do_test(fignum, actual_fname, expected_fname):
268268

269269
def image_comparison(baseline_images=None, extensions=None, tol=0,
270270
freetype_version=None, remove_text=False,
271-
savefig_kwarg=None, style='classic'):
271+
savefig_kwarg=None, style='_classic_test'):
272272
"""
273273
Compare images generated by the test with those specified in
274274
*baseline_images*, which must correspond else an
275275
ImageComparisonFailure exception will be raised.
276276
277-
Keyword arguments:
277+
Arguments
278+
---------
279+
baseline_images : list
280+
A list of strings specifying the names of the images generated by
281+
calls to :meth:`matplotlib.figure.savefig`.
278282
279-
*baseline_images*: list
280-
A list of strings specifying the names of the images generated
281-
by calls to :meth:`matplotlib.figure.savefig`.
282-
283-
*extensions*: [ None | list ]
284-
285-
If *None*, default to all supported extensions.
283+
extensions : [ None | list ]
286284
285+
If None, defaults to all supported extensions.
287286
Otherwise, a list of extensions to test. For example ['png','pdf'].
288287
289-
*tol*: (default 0)
288+
tol : float, optional, default: 0
290289
The RMS threshold above which the test is considered failed.
291290
292-
*freetype_version*: str or tuple
293-
The expected freetype version or range of versions for this
294-
test to pass.
291+
freetype_version : str or tuple
292+
The expected freetype version or range of versions for this test to
293+
pass.
295294
296-
*remove_text*: bool
297-
Remove the title and tick text from the figure before
298-
comparison. This does not remove other, more deliberate,
299-
text, such as legends and annotations.
295+
remove_text : bool
296+
Remove the title and tick text from the figure before comparison.
297+
This does not remove other, more deliberate, text, such as legends and
298+
annotations.
300299
301-
*savefig_kwarg*: dict
300+
savefig_kwarg : dict
302301
Optional arguments that are passed to the savefig method.
303302
304-
*style*: string
305-
Optional name for the base style to apply to the image
306-
test. The test itself can also apply additional styles
307-
if desired. Defaults to the 'classic' style.
303+
style : string
304+
Optional name for the base style to apply to the image test. The test
305+
itself can also apply additional styles if desired. Defaults to the
306+
'_classic_test' style.
308307
309308
"""
310309
if baseline_images is None:

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ def test_bar_tick_label_multiple():
11431143
ax.bar([1, 2.5], [1, 2], width=[0.2, 0.5], tick_label=['a', 'b'],
11441144
align='center')
11451145

1146-
@image_comparison(baseline_images=['bar_tick_label_multiple_old_alignment'],
1146+
@image_comparison(baseline_images=['bar_tick_label_multiple_old_label_alignment'],
11471147
extensions=['png'])
11481148
def test_bar_tick_label_multiple_old_alignment():
11491149
# From 2516: plot bar with array of string labels for x axis

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def create_figure():
7878

7979

8080
# test compiling a figure to pdf with xelatex
81-
@cleanup(style='classic')
81+
@cleanup(style='_classic_test')
8282
@switch_backend('pgf')
8383
def test_xelatex():
8484
if not check_for('xelatex'):
@@ -92,7 +92,7 @@ def test_xelatex():
9292

9393

9494
# test compiling a figure to pdf with pdflatex
95-
@cleanup(style='classic')
95+
@cleanup(style='_classic_test')
9696
@switch_backend('pgf')
9797
def test_pdflatex():
9898
if not check_for('pdflatex'):
@@ -109,7 +109,7 @@ def test_pdflatex():
109109

110110

111111
# test updating the rc parameters for each figure
112-
@cleanup(style='classic')
112+
@cleanup(style='_classic_test')
113113
@switch_backend('pgf')
114114
def test_rcupdate():
115115
if not check_for('xelatex') or not check_for('pdflatex'):
@@ -142,7 +142,7 @@ def test_rcupdate():
142142

143143

144144
# test backend-side clipping, since large numbers are not supported by TeX
145-
@cleanup(style='classic')
145+
@cleanup(style='_classic_test')
146146
@switch_backend('pgf')
147147
def test_pathclip():
148148
if not check_for('xelatex'):
@@ -161,7 +161,7 @@ def test_pathclip():
161161

162162

163163
# test mixed mode rendering
164-
@cleanup(style='classic')
164+
@cleanup(style='_classic_test')
165165
@switch_backend('pgf')
166166
def test_mixedmode():
167167
if not check_for('xelatex'):
@@ -178,7 +178,7 @@ def test_mixedmode():
178178

179179

180180
# test bbox_inches clipping
181-
@cleanup(style='classic')
181+
@cleanup(style='_classic_test')
182182
@switch_backend('pgf')
183183
def test_bbox_inches():
184184
if not check_for('xelatex'):

lib/matplotlib/tests/test_ticker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import warnings
1414

1515

16-
@cleanup(style='classic')
16+
@cleanup(style='_classic_test')
1717
def test_MaxNLocator():
1818
loc = mticker.MaxNLocator(nbins=5)
1919
test_value = np.array([20., 40., 60., 80., 100.])
@@ -172,7 +172,7 @@ def test_SymmetricalLogLocator_set_params():
172172
nose.tools.assert_equal(sym.numticks, 8)
173173

174174

175-
@cleanup(style='classic')
175+
@cleanup(style='_classic_test')
176176
def test_ScalarFormatter_offset_value():
177177
fig, ax = plt.subplots()
178178
formatter = ax.get_xaxis().get_major_formatter()

0 commit comments

Comments
 (0)