Skip to content

Backports for 3.0 #12129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exclude =

per-file-ignores =
setup.py: E402
setupext.py: E302, E501
setupext.py: E501

tools/compare_backend_driver_results.py: E501
tools/subset.py: E221, E231, E251, E261, E302, E501, E701
Expand Down
2 changes: 1 addition & 1 deletion doc-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Install the documentation requirements with:
# pip install -r doc-requirements.txt
#
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3,<1.8
sphinx>=1.3,!=1.5.0,!=1.6.4,!=1.7.3
colorspacious
ipython
ipywidgets
Expand Down
5 changes: 4 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ def _check_deps():
autosummary_generate = True

autodoc_docstring_signature = True
autodoc_default_flags = ['members', 'undoc-members']
if sphinx.version_info < (1, 8):
autodoc_default_flags = ['members', 'undoc-members']
else:
autodoc_default_options = {'members': None, 'undoc-members': None}

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
Expand Down
4 changes: 0 additions & 4 deletions doc/sphinxext/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
app = inliner.document.settings.env.app
#app.info('issue %r' % text)
if 'pull' in name.lower():
category = 'pull'
elif 'issue' in name.lower():
Expand Down Expand Up @@ -105,7 +104,6 @@ def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
:param content: The directive content for customization.
"""
app = inliner.document.settings.env.app
#app.info('user link %r' % text)
ref = 'https://www.github.com/' + text
node = nodes.reference(rawtext, text, refuri=ref, **options)
return [node], []
Expand All @@ -126,7 +124,6 @@ def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
:param content: The directive content for customization.
"""
app = inliner.document.settings.env.app
#app.info('user link %r' % text)
try:
base = app.config.github_project_url
if not base:
Expand All @@ -146,7 +143,6 @@ def setup(app):

:param app: Sphinx application context.
"""
app.info('Initializing GitHub plugin')
app.add_role('ghissue', ghissue_role)
app.add_role('ghpull', ghissue_role)
app.add_role('ghuser', ghuser_role)
Expand Down
12 changes: 0 additions & 12 deletions doc/users/next_whats_new/2018-09-06-AL.rst

This file was deleted.

23 changes: 23 additions & 0 deletions doc/users/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,29 @@ Headless linux servers (identified by the DISPLAY env not being defined)
will not select a GUI backend.


Return type of ArtistInspector.get_aliases changed
``````````````````````````````````````````````````

`ArtistInspector.get_aliases` previously returned the set of aliases as
``{fullname: {alias1: None, alias2: None, ...}}``. The dict-to-None mapping
was used to simulate a set in earlier versions of Python. It has now been
replaced by a set, i.e. ``{fullname: {alias1, alias2, ...}}``.

This value is also stored in `ArtistInspector.aliasd`, which has likewise
changed.


``:math:`` directive renamed to ``:mathmpl:``
`````````````````````````````````````````````

The ``:math:`` rst role provided by `matplotlib.sphinxext.mathmpl` has been
renamed to ``:mathmpl:`` to avoid conflicting with the ``:math:`` role that
Sphinx 1.8 provides by default. (``:mathmpl:`` uses Matplotlib to render math
expressions to images embedded in html, whereas Sphinx uses MathJax.)

When using Sphinx<1.8, both names (``:math:`` and ``:mathmpl:``) remain
available for backcompatibility.


==================
Previous Whats New
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ def __call__(self):
vmin = self._colorbar.norm.vmin
vmax = self._colorbar.norm.vmax
ticks = ticker.AutoMinorLocator.__call__(self)
return ticks[(ticks >= vmin) & (ticks <= vmax)]
rtol = (vmax - vmin) * 1e-10
return ticks[(ticks >= vmin - rtol) & (ticks <= vmax + rtol)]


class _ColorbarLogLocator(ticker.LogLocator):
Expand Down
15 changes: 10 additions & 5 deletions lib/matplotlib/sphinxext/mathmpl.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import hashlib
import os
import sys
from hashlib import md5
import warnings

from docutils import nodes
from docutils.parsers.rst import directives
import warnings
import sphinx

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

destdir = os.path.join(setup.app.builder.outdir, '_images', 'mathmpl')
if not os.path.exists(destdir):
Expand Down Expand Up @@ -110,9 +111,13 @@ def depart_latex_math_latex(self, node):
app.add_node(latex_math,
html=(visit_latex_math_html, depart_latex_math_html),
latex=(visit_latex_math_latex, depart_latex_math_latex))
app.add_role('math', math_role)
app.add_directive('math', math_directive,
app.add_role('mathmpl', math_role)
app.add_directive('mathmpl', math_directive,
True, (0, 0, 0), **options_spec)
if sphinx.version_info < (1, 8):
app.add_role('math', math_role)
app.add_directive('math', math_directive,
True, (0, 0, 0), **options_spec)

metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
return metadata
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,15 @@ def test_colorbar_minorticks_on_off():
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
np.array([]))

im.set_clim(vmin=-1.2, vmax=1.2)
cbar.minorticks_on()
correct_minorticklocs = np.array([-1.2, -1.1, -0.9, -0.8, -0.7, -0.6,
-0.4, -0.3, -0.2, -0.1, 0.1, 0.2,
0.3, 0.4, 0.6, 0.7, 0.8, 0.9,
1.1, 1.2])
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
correct_minorticklocs)


def test_colorbar_autoticks():
# Test new autotick modes. Needs to be classic because
Expand Down
9 changes: 1 addition & 8 deletions setup.cfg.template
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,9 @@
# behavior
#
#agg = auto
#cairo = auto
#gtk3agg = auto
#gtk3cairo = auto
#macosx = auto
#pyside = auto
#qt4agg = auto
#tkagg = auto
#windowing = auto
#wxagg = auto

[rc_options]
# User-configurable options
Expand All @@ -81,10 +75,9 @@
#
# The Agg, Ps, Pdf and SVG backends do not require external dependencies. Do
# not choose MacOSX, or TkAgg if you have disabled the relevant extension
# modules. Agg will be used by default.
# modules. The default is determined by fallback.
#
#backend = Agg
#

[package_data]
# Package additional files found in the lib/matplotlib directories.
Expand Down
32 changes: 10 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,9 @@
setupext.Tests(),
setupext.Toolkits_Tests(),
'Optional backend extensions',
# These backends are listed in order of preference, the first
# being the most preferred. The first one that looks like it will
# work will be selected as the default backend.
setupext.BackendMacOSX(),
setupext.BackendQt5(),
setupext.BackendQt4(),
setupext.BackendGtk3Agg(),
setupext.BackendGtk3Cairo(),
setupext.BackendTkAgg(),
setupext.BackendWxAgg(),
setupext.BackendAgg(),
setupext.BackendCairo(),
setupext.BackendTkAgg(),
setupext.BackendMacOSX(),
setupext.Windowing(),
'Optional package data',
setupext.Dlls(),
Expand Down Expand Up @@ -133,7 +124,6 @@ def run(self):
package_dir = {'': 'lib'}
install_requires = []
setup_requires = []
default_backend = None

# If the user just queries for information, don't bother figuring out which
# packages to build or install.
Expand Down Expand Up @@ -169,10 +159,6 @@ def run(self):
required_failed.append(package)
else:
good_packages.append(package)
if (isinstance(package, setupext.OptionalBackendPackage)
and package.runtime_check()
and default_backend is None):
default_backend = package.name
print_raw('')

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

# Write the default matplotlibrc file
if default_backend is None:
default_backend = 'svg'
if setupext.options['backend']:
default_backend = setupext.options['backend']
with open('matplotlibrc.template') as fd:
template = fd.read()
template_lines = fd.read().splitlines(True)
backend_line_idx, = [ # Also asserts that there is a single such line.
idx for idx, line in enumerate(template_lines)
if line.startswith('#backend ')]
if setupext.options['backend']:
template_lines[backend_line_idx] = (
'backend: {}'.format(setupext.options['backend']))
with open('lib/matplotlib/mpl-data/matplotlibrc', 'w') as fd:
fd.write(template)
fd.write(''.join(template_lines))

# Finalize the extension modules so they can get the Numpy include
# dirs
Expand Down
Loading