8000 Merge pull request #12245 from anntzer/kill22 · matplotlib/matplotlib@4614a26 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4614a26

Browse files
authored
Merge pull request #12245 from anntzer/kill22
Remove (some) features deprecated in mpl2.2
2 parents de38ef2 + 893a0a3 commit 4614a26

24 files changed

+76
-510
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
API removals
2+
````````````
3+
4+
The following deprecated APIs were removed:
5+
6+
Classes and methods
7+
-------------------
8+
- ``Verbose`` (replaced by python logging library)
9+
- ``artist.Artist.hitlist`` (no replacement)
10+
- ``artist.Artist.is_figure_set`` (use ``artist.figure is not None`` instead)
11+
- ``axis.Axis.unit_data`` (use ``axis.Axis.units`` instead)
12+
- ``backend_bases.FigureCanvasBase.onRemove`` (no replacement)
13+
``backend_bases.FigureManagerBase.show_popup`` (this never did anything)
14+
- ``backend_wx.SubplotToolWx`` (no replacement)
15+
- ``backend_wx.Toolbar`` (use ``backend_wx.NavigationToolbar2Wx`` instead)
16+
- ``cbook.align_iterators`` (no replacment)
17+
- ``contour.ContourLabeler.get_real_label_width`` (no replacement)
18+
- ``legend.Legend.draggable`` (use `legend.Legend.set_draggable()` instead)
19+
- ``texmanager.TexManager.postscriptd``, ``texmanager.TexManager.pscnt``,
20+
``texmanager.TexManager.make_ps``, ``texmanager.TexManager.get_ps_bbox``
21+
(no replacements)
22+
23+
Arguments
24+
---------
25+
- The ``fig`` kwarg to ``GridSpec.get_subplot_params`` and
26+
``GridSpecFromSubplotSpec.get_subplot_params`` (use the argument
27+
``figure`` instead)
28+
- Passing 'box-forced' to `axes.Axes.set_adjustable` (use 'box' instead)
29+
- Support for the strings 'on'/'true'/'off'/'false' to mean
30+
``True``/``False`` (directly use ``True``/``False`` instead).
31+
The following functions are affected: `Axes.grid`, `Axes3D.grid`
32+
`Axis.set_tick_params`, `pyplot.box`.
33+
- Using `pyplot.axes` with an `axes.Axes` type argument
34+
(use `pyplot.sca` instead)
35+
36+
Other
37+
-----
38+
- svgfont support (in :rc:`svg.fonttype`) has been removed,
39+
- Logging is now done with the standard python ``logging`` library.
40+
``matplotlib.verbose`` and the command line switches ``--verbose-LEVEL`` are
41+
removed.
42+
43+
To control the logging output use::
44 F438 +
45+
import logging
46+
logger = logging.getLogger('matplotlib')
47+
logger.set_level(logging.INFO)

doc/devel/MEP/MEP14.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ difficult to fix over time.
188188

189189
Instead, we should be able to use FreeType to get the font outlines
190190
and write our own code (probably in Python) to output subsetted fonts
191-
(Type 3 on PS and PDF and SVGFonts or paths on SVG). Freetype, as a
192-
popular and well-maintained project, handles a wide variety of fonts
193-
in the wild. This would remove a lot of custom C code, and remove
194-
some code duplication between backends.
191+
(Type 3 on PS and PDF and paths on SVG). Freetype, as a popular and
192+
well-maintained project, handles a wide variety of fonts in the wild.
193+
This would remove a lot of custom C code, and remove some code
194+
duplication between backends.
195195

196196
Note that subsetting fonts this way, while the easiest route, does
197197
lose the hinting in the font, so we will need to continue, as we do

lib/matplotlib/__init__.py

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -251,132 +251,6 @@ def _set_logger_verbose_level(level_str='silent', file_str='sys.stdout'):
251251
_log.addHandler(console)
252252

253253

254-
def _parse_commandline():
255-
"""
256-
Check for --verbose-LEVEL type command line arguments and
257-
set logging level appropriately.
258-
"""
259-
260-
levels = ('silent', 'helpful', 'debug', 'debug-annoying',
261-
'info', 'warning')
262-
263-
for arg in sys.argv[1:]:
264-
if arg.startswith('--verbose-'):
265-
level_str = arg[10:]
266-
# If it doesn't match one of ours, then don't even
267-
# bother noting it, we are just a 3rd-party library
268-
# to somebody else's script.
269-
if level_str in levels:
270-
_set_logger_verbose_level(level_str)
271-
272-
_parse_commandline()
273-
274-
275-
class Verbose(object):
276-
"""
277-
A class to handle reporting. Set the fileo attribute to any file
278-
instance to handle the output. Default is sys.stdout
279-
"""
280-
levels = ('silent', 'helpful', 'debug', 'debug-annoying')
281-
vald = {level: i for i, level in enumerate(levels)}
282-
283-
# parse the verbosity from the command line; flags look like
284-
# --verbose-silent or --verbose-helpful
285-
_commandLineVerbose = None
286-
287-
for arg in sys.argv[1:]:
288-
if not arg.startswith('--verbose-'):
289-
continue
290-
level_str = arg[10:]
291-
# If it doesn't match one of ours, then don't even
292-
# bother noting it, we are just a 3rd-party library
293-
# to somebody else's script.
294-
if level_str in levels:
295-
_commandLineVerbose = level_str
296-
297-
@cbook.deprecated("2.2", message=_verbose_msg)
298-
def __init__(self):
299-
self.set_level('silent')
300-
self.fileo = sys.stdout
301-
302-
@cbook.deprecated("2.2", message=_verbose_msg)
303-
def set_level(self, level):
304-
'set the verbosity to one of the Verbose.levels strings'
305-
306-
if self._commandLineVerbose is not None:
307-
level = self._commandLineVerbose
308-
if level not in self.levels:
309-
cbook._warn_external('matplotlib: unrecognized --verbose-* '
310-
'string "%s". Legal values are %s' %
311-
(level, self.levels))
312-
else:
313-
self.level = level
314-
315-
@cbook.deprecated("2.2", message=_verbose_msg)
316-
def set_fileo(self, fname):
317-
std = {
318-
'sys.stdout': sys.stdout,
319-
'sys.stderr': sys.stderr,
320-
}
321-
if fname in std:
322-
self.fileo = std[fname]
323-
else:
324-
try:
325-
fileo = open(fname, 'w')
326-
except IOError:
327-
raise ValueError('Verbose object could not open log file "{0}"'
328-
' for writing.\nCheck your matplotlibrc '
329-
'verbose.fileo setting'.format(fname))
330-
else:
331-
self.fileo = fileo
332-
333-
@cbook.deprecated("2.2", message=_verbose_msg)
334-
def report(self, s, level='helpful'):
335-
"""
336-
print message s to self.fileo if self.level>=level. Return
337-
value indicates whether a message was issued
338-
339-
"""
340-
if self.ge(level):
341-
print(s, file=self.fileo)
342-
return True
343-
return False
344-
345-
@cbook.deprecated("2.2", message=_verbose_msg)
346-
def wrap(self, fmt, func, level='helpful', always=True):
347-
"""
348-
return a callable function that wraps func and reports it
349-
output through the verbose handler if current verbosity level
350-
is higher than level
351-
352-
if always is True, the report will occur on every function
353-
call; otherwise only on the first time the function is called
354-
"""
355-
assert callable(func)
356-
357-
def wrapper(*args, **kwargs):
358-
ret = func(*args, **kwargs)
359-
360-
if (always or not wrapper._spoke):
361-
spoke = self.report(fmt % ret, level)
362-
if not wrapper._spoke:
363-
wrapper._spoke = spoke
364-
return ret
365-
wrapper._spoke = False
366-
wrapper.__doc__ = func.__doc__
367-
return wrapper
368-
369-
@cbook.deprecated("2.2", message=_verbose_msg)
370-
def ge(self, level):
371-
'return true if self.level is >= level'
372-
return self.vald[self.level] >= self.vald[level]
373-
374-
375-
with warnings.catch_warnings():
376-
warnings.simplefilter("ignore")
377-
verbose = Verbose()
378-
379-
380254
def _logged_cached(fmt, func=None):
381255
"""
382256
Decorator that logs a function's return value, and memoizes that value.

lib/matplotlib/artist.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -359,25 +359,6 @@ def get_transform(self):
359359
self._transform = self._transform._as_mpl_transform(self.axes)
360360
return self._transform
361361

362-
@cbook.deprecated("2.2")
363-
def hitlist(self, event):
364-
"""
365-
List the children of the artist which contain the mouse event *event*.
366-
"""
367-
L = []
368-
try:
369-
hascursor, info = self.contains(event)
370-
if hascursor:
371-
L.append(self)
372-
except Exception:
373-
import traceback
374-
traceback.print_exc()
375-
print("while checking", self.__class__)
376-
377-
for a in self.get_children():
378-
L.extend(a.hitlist(event))
379-
return L
380-
381362
def get_children(self):
382363
r"""Return a list of the child `.Artist`\s of this `.Artist`."""
383364
return []
@@ -535,11 +516,6 @@ def get_picker(self):
535516
"""
536517
return self._picker
537518

538-
@cbook.deprecated("2.2", alternative="artist.figure is not None")
539-
def is_figure_set(self):
540-
"""Returns whether the artist is assigned to a `.Figure`."""
541-
return self.figure is not None
542-
543519
def get_url(self):
544520
"""Return the url."""
545521
return self._url

lib/matplotlib/axes/_axes.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6473,15 +6473,13 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64736473
Returns
64746474
-------
64756475
n : array or list of arrays
6476-
The values of the histogram bins. See *normed* or *density*
6477-
and *weights* for a description of the possible semantics.
6478-
If input *x* is an array, then this is an array of length
6479-
*nbins*. If input is a sequence of arrays
6480-
``[data1, data2,..]``, then this is a list of arrays with
6481-
the values of the histograms for each of the arrays in the
6482-
same order. The dtype of the elements of the array *n*
6483-
(or of its element arrays) will always be float even if no
6484-
weighting or normalization is used.
6476+
The values of the histogram bins. See *density* and *weights* for a
6477+
description of the possible semantics. If input *x* is an array,
6478+
then this is an array of length *nbins*. If input is a sequence of
6479+
arrays ``[data1, data2,..]``, then this is a list of arrays with
6480+
the values of the histograms for each of the arrays in the same
6481+
order. The dtype of the array *n* (or of its element arrays) will
6482+
always be float even if no weighting or normalization is used.
64856483
64866484
bins : array
64876485
The edges of the bins. Length nbins + 1 (nbins left edges and right

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
import matplotlib as mpl
1212
from matplotlib import cbook, rcParams
13-
from matplotlib.cbook import (
14-
_OrderedSet, _check_1d, _string_to_bool, index_of, get_label)
13+
from matplotlib.cbook import _OrderedSet, _check_1d, index_of, get_label
1514
from matplotlib import docstring
1615
import matplotlib.colors as mcolors
1716
import matplotlib.lines as mlines
@@ -1322,10 +1321,7 @@ def set_adjustable(self, adjustable, share=False):
13221321
which the adjustments for aspect ratios are done sequentially
13231322
and independently on each Axes as it is drawn.
13241323
"""
1325-
if adjustable == 'box-forced':
1326-
cbook.warn_deprecated(
1327-
"2.2", name="box-forced", obj_type="keyword argument")
1328-
if adjustable not in ('box', 'datalim', 'box-forced'):
1324+
if adjustable not in ('box', 'datalim'):
13291325
raise ValueError("argument must be 'box', or 'datalim'")
13301326
if share:
13311327
axes = set(self._shared_x_axes.get_siblings(self)
@@ -1491,7 +1487,7 @@ def apply_aspect(self, position=None):
14911487

14921488
figW, figH = self.get_figure().get_size_inches()
14931489
fig_aspect = figH / figW
1494-
if self._adjustable in ['box', 'box-forced']:
1490+
if self._adjustable == 'box':
14951491
if self in self._twinned_axes:
14961492
raise RuntimeError("Adjustable 'box' is not allowed in a"
14971493
" twinned Axes. Use 'datalim' instead.")
@@ -2739,9 +2735,6 @@ def grid(self, b=None, which='major', axis='both', **kwargs):
27392735
"""
27402736
if len(kwargs):
27412737
b = True
2742-
elif b is not None:
2743-
b = _string_to_bool(b)
2744-
27452738
if axis not in ['x', 'y', 'both']:
27462739
raise ValueError("The argument 'axis' must be one of 'x', 'y' or "
27472740
"'both'.")

lib/matplotlib/axis.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from matplotlib import rcParams
1111
import matplotlib.artist as martist
1212
import matplotlib.cbook as cbook
13-
from matplotlib.cbook import _string_to_bool
1413
import matplotlib.font_manager as font_manager
1514
import matplotlib.lines as mlines
1615
import matplotlib.scale as mscale
@@ -758,15 +757,6 @@ def _set_scale(self, value, **kwargs):
758757
def limit_range_for_scale(self, vmin, vmax):
759758
return self._scale.limit_range_for_scale(vmin, vmax, self.get_minpos())
760759

761-
@cbook.deprecated("2.2.0")
762-
@property
763-
def unit_data(self):
764-
return self.units
765-
766-
@unit_data.setter
767-
def unit_data(self, unit_data):
768-
self.set_units(unit_data)
769-
770760
def get_children(self):
771761
children = [self.label, self.offsetText]
772762
majorticks = self.get_major_ticks()
@@ -852,8 +842,7 @@ def set_tick_params(self, which='major', reset=False, **kw):
852842

853843
@staticmethod
854844
def _translate_tick_kw(kw):
855-
# The following lists may be moved to a more
856-
# accessible location.
845+
# The following lists may be moved to a more accessible location.
857846
kwkeys = ['size', 'width', 'color', 'tickdir', 'pad',
858847
'labelsize', 'labelcolor', 'zorder', 'gridOn',
859848
'tick1On', 'tick2On', 'label1On', 'label2On',
@@ -868,21 +857,21 @@ def _translate_tick_kw(kw):
868857
if 'rotation' in kw:
869858
kwtrans['labelrotation'] = kw.pop('rotation')
870859
if 'left' in kw:
871-
kwtrans['tick1On'] = _string_to_bool(kw.pop('left'))
860+
kwtrans['tick1On'] = kw.pop('left')
872861
if 'bottom' in kw:
873-
kwtrans['tick1On'] = _string_to_bool(kw.pop('bottom'))
862+
kwtrans['tick1On'] = kw.pop('bottom')
874863
if 'right' in kw:
875-
kwtrans['tick2On'] = _string_to_bool(kw.pop('right'))
864+
kwtrans['tick2On'] = kw.pop('right')
876865
if 'top' in kw:
877-
kwtrans['tick2On'] = _string_to_bool(kw.pop('top'))
866+
kwtrans['tick2On'] = kw.pop('top')
878867
if 'labelleft' in kw:
879-
kwtrans['label1On'] = _string_to_bool(kw.pop('labelleft'))
868+
kwtrans['label1On'] = kw.pop('labelleft')
880869
if 'labelbottom' in kw:
881-
kwtrans['label1On'] = _string_to_bool(kw.pop('labelbottom'))
870+
kwtrans['label1On'] = kw.pop('labelbottom')
882871
if 'labelright' in kw:
883-
kwtrans['label2On'] = _string_to_bool(kw.pop('labelright'))
872+
kwtrans['label2On'] = kw.pop('labelright')
884873
if 'labeltop' in kw:
885-
kwtrans['label2On'] = _string_to_bool(kw.pop('labeltop'))
874+
kwtrans['label2On'] = kw.pop('labeltop')
886875
if 'colors' in kw:
887876
c = kw.pop('colors')
888877
kwtrans['color'] = c

0 commit comments

Comments
 (0)
0