8000 Merge pull request #12129 from tacaswell/backport_12128 · matplotlib/matplotlib@3831542 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3831542

Browse files
authored
Merge pull request #12129 from tacaswell/backport_12128
Backports for 3.0
2 parents a9402c0 + 9fb90d4 commit 3831542

File tree

13 files changed

+82
-306
lines changed

13 files changed

+82
-306
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exclude =
2323

2424
per-file-ignores =
2525
setup.py: E402
26-
setupext.py: E302, E501
26+
setupext.py: E501
2727

2828
tools/compare_backend_driver_results.py: E501
2929
tools/subset.py: E221, E231, E251, E261, E302, E501, E701

doc-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Install the documentation requirements with:
77
# pip install -r doc-requirements.txt
88
#
9-
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3,<1.8
9+
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3
1010
colorspacious
1111
ipython
1212
ipywidgets

doc/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ def _check_deps():
8484
autosummary_generate = True
8585

8686
autodoc_docstring_signature = True
87-
autodoc_default_flags = ['members', 'undoc-members']
87+
if sphinx.version_info < (1, 8):
88+
autodoc_default_flags = ['members', 'undoc-members']
89+
else:
90+
autodoc_default_options = {'members': None, 'undoc-members': None}
8891

8992
intersphinx_mapping = {
9093
'python': ('https://docs.python.org/3', None),

doc/sphinxext/github.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
7575
prb = inliner.problematic(rawtext, rawtext, msg)
7676
return [prb], [msg]
7777
app = inliner.document.settings.env.app
78-
#app.info('issue %r' % text)
7978
if 'pull' in name.lower():
8079
category = 'pull'
8180
elif 'issue' in name.lower():
@@ -105,7 +104,6 @@ def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
105104
:param content: The directive content for customization.
106105
"""
107106
app = inliner.document.settings.env.app
108-
#app.info('user link %r' % text)
109107
ref = 'https://www.github.com/' + text
110108
node = nodes.reference(rawtext, text, refuri=ref, **options)
111109
return [node], []
@@ -126,7 +124,6 @@ def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
126124
:param content: The directive content for customization.
127125
"""
128126
app = inliner.document.settings.env.app
129-
#app.info('user link %r' % text)
130127
try:
131128
base = app.config.github_project_url
132129
if not base:
@@ -146,7 +143,6 @@ def setup(app):
146143
147144
:param app: Sphinx application conte A92E xt.
148145
"""
149-
app.info('Initializing GitHub plugin')
150146
app.add_role('ghissue', ghissue_role)
151147
app.add_role('ghpull', ghissue_role)
152148
app.add_role('ghuser', ghuser_role)

doc/users/next_whats_new/2018-09-06-AL.rst

Lines changed: 0 additions & 12 deletions
This file was deleted.

doc/users/whats_new.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,29 @@ Headless linux servers (identified by the DISPLAY env not being defined)
239239
will not select a GUI backend.
240240

241241

242+
Return type of ArtistInspector.get_aliases changed
243+
``````````````````````````````````````````````````
244+
245+
`ArtistInspector.get_aliases` previously returned the set of aliases as
246+
``{fullname: {alias1: None, alias2: None, ...}}``. The dict-to-None mapping
247+
was used to simulate a set in earlier versions of Python. It has now been
248+
replaced by a set, i.e. ``{fullname: {alias1, alias2, ...}}``.
249+
250+
This value is also stored in `ArtistInspector.aliasd`, which has likewise
251+
changed.
252+
253+
254+
``:math:`` directive renamed to ``:mathmpl:``
255+
`````````````````````````````````````````````
256+
257+
The ``:math:`` rst role provided by `matplotlib.sphinxext.mathmpl` has been
258+
renamed to ``:mathmpl:`` to avoid conflicting with the ``:math:`` role that
259+
Sphinx 1.8 provides by default. (``:mathmpl:`` uses Matplotlib to render math
260+
expressions to images embedded in html, whereas Sphinx uses MathJax.)
261+
262+
When using Sphinx<1.8, both names (``:math:`` and ``:mathmpl:``) remain
263+
available for backcompatibility.
264+
242265

243266
==================
244267
Previous Whats New

lib/matplotlib/colorbar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ def __call__(self):
267267
vmin = self._colorbar.norm.vmin
268268
vmax = self._colorbar.norm.vmax
269269
ticks = ticker.AutoMinorLocator.__call__(self)
270-
return ticks[(ticks >= vmin) & (ticks <= vmax)]
270+
rtol = (vmax - vmin) * 1e-10
271+
return ticks[(ticks >= vmin - rtol) & (ticks <= vmax + rtol)]
271272

272273

273274
class _ColorbarLogLocator(ticker.LogLocator):

lib/matplotlib/sphinxext/mathmpl.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import hashlib
12
import os
23
import sys
3-
from hashlib import md5
4+
import warnings
45

56
from docutils import nodes
67
from docutils.parsers.rst import directives
7-
import warnings
8+
import sphinx
89

910
from matplotlib import rcParams
1011
from matplotlib.mathtext import MathTextParser
@@ -61,7 +62,7 @@ def latex2png(latex, filename, fontset='cm'):
6162
def latex2html(node, source):
6263
inline = isinstance(node.parent, nodes.TextElement)
6364
latex = node['latex']
64-
name = 'math-%s' % md5(latex.encode()).hexdigest()[-10:]
65+
name = 'math-%s' % hashlib.md5(latex.encode()).hexdigest()[-10:]
6566

6667
destdir = os.path.join(setup.app.builder.outdir, '_images', 'mathmpl')
6768
if not os.path.exists(destdir):
@@ -110,9 +111,13 @@ def depart_latex_math_latex(self, node):
110111
app.add_node(latex_math,
111112
html=(visit_latex_math_html, depart_latex_math_html),
112113
latex=(visit_latex_math_latex, depart_latex_math_latex))
113-
app.add_role('math', math_role)
114-
app.add_directive('math', math_directive,
114+
app.add_role('mathmpl', math_role)
115+
app.add_directive('mathmpl', math_directive,
115116
True, (0, 0, 0), **options_spec)
117+
if sphinx.version_info < (1, 8):
118+
app.add_role('math', math_role)
119+
app.add_directive('math', math_directive,
120+
True, (0, 0, 0), **options_spec)
116121

117122
metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
118123
return metadata

lib/matplotlib/tests/test_colorbar.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ def test_colorbar_minorticks_on_off():
294294
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
295295
np.array([]))
296296

297+
im.set_clim(vmin=-1.2, vmax=1.2)
298+
cbar.minorticks_on()
299+
correct_minorticklocs = np.array([-1.2, -1.1, -0.9, -0.8, -0.7, -0.6,
300+
-0.4, -0.3, -0.2, -0.1, 0.1, 0.2,
301+
0.3, 0.4, 0.6, 0.7, 0.8, 0.9,
302+
1.1, 1.2])
303+
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
304+
correct_minorticklocs)
305+
297306

298307
def test_colorbar_autoticks():
299308
# Test new autotick modes. Needs to be classic because

setup.cfg.template

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,9 @@
6363
# behavior
6464
#
6565
#agg = auto
66-
#cairo = auto
67-
#gtk3agg = auto
68-
#gtk3cairo = auto
6966
#macosx = auto
70-
#pyside = auto
71-
#qt4agg = auto
7267
#tkagg = auto
7368
#windowing = auto
74-
#wxagg = auto
7569

7670
[rc_options]
7771
# User-configurable options
@@ -81,10 +75,9 @@
8175
#
8276
# The Agg, Ps, Pdf and SVG backends do not require external dependencies. Do
8377
# not choose MacOSX, or TkAgg if you have disabled the relevant extension
84-
# modules. Agg will be used by default.
78+
# modules. The default is determined by fallback.
8579
#
8680
#backend = Agg
87-
#
8881

8982
[package_data]
9083
# Package additional files found in the lib/matplotlib directories.

setup.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,9 @@
7070
setupext.Tests(),
7171
setupext.Toolkits_Tests(),
7272
'Optional backend extensions',
73-
# These backends are listed in order of preference, the first
74-
# being the most preferred. The first one that looks like it will
75-
# work will be selected as the default backend.
76-
setupext.BackendMacOSX(),
77-
setupext.BackendQt5(),
78-
setupext.BackendQt4(),
79-
setupext.BackendGtk3Agg(),
80-
setupext.BackendGtk3Cairo(),
81-
setupext.BackendTkAgg(),
82-
setupext.BackendWxAgg(),
8373
setupext.BackendAgg(),
84-
setupext.BackendCairo(),
74+
setupext.BackendTkAgg(),
75+
setupext.BackendMacOSX(),
8576
setupext.Windowing(),
8677
'Optional package data',
8778
setupext.Dlls(),
@@ -133,7 +124,6 @@ def run(self):
133124
package_dir = {'': 'lib'}
134125
install_requires = []
135126
setup_requires = []
136-
default_backend = None
137127

138128
# If the user just queries for information, don't bother figuring out which
139129
# packages to build or install.
@@ -169,10 +159,6 @@ def run(self):
169159
required_failed.append(package)
170160
else:
171161
good_packages.append(package)
172-
if (isinstance(package, setupext.OptionalBackendPackage)
173-
and package.runtime_check()
174-
and default_backend is None):
175-
default_backend = package.name
176162
print_raw('')
177163

178164
# Abort if any of the required packages can not be built.
@@ -203,14 +189,16 @@ def run(self):
203189
setup_requires.extend(package.get_setup_requires())
204190

205191
# Write the default matplotlibrc file
206-
if default_backend is None:
207-
default_backend = 'svg'
208-
if setupext.options['backend']:
209-
default_backend = setupext.options['backend']
210192
with open('matplotlibrc.template') as fd:
211-
template = fd.read()
193+
template_lines = fd.read().splitlines(True)
194+
backend_line_idx, = [ # Also asserts that there is a single such line.
195+
idx for idx, line in enumerate(template_lines)
196+
if line.startswith('#backend ')]
197+
if setupext.options['backend']:
198+
template_lines[backend_line_idx] = (
199+
'backend: {}'.format(setupext.options['backend']))
212200
with open('lib/matplotlib/mpl-data/matplotlibrc', 'w') as fd:
213-
fd.write(template)
201+
fd.write(''.join(template_lines))
214202

215203
# Finalize the extension modules so they can get the Numpy include
216204
# dirs

0 commit comments

Comments
 (0)
0