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

Skip to content

Commit 04aea74

Browse files
committed
Remove (most) APIs deprecated in mpl2.2.
1 parent 0c35833 commit 04aea74

23 files changed

+56
-518
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
API removals
2+
````````````
3+
4+
The following deprecated APIs were removed:
5+
6+
- ``Verbose``,
7+
- ``artist.Artist.hitlist``, ``artist.Artist.is_figure_set``,
8+
- ``axis.Axis.unit_data``,
9+
- ``backend_bases.FigureCanvasBase.onRemove``,
10+
``backend_bases.FigureManagerBase.show_popup``,
11+
- ``backend_wx.SubplotToolWx``, ``backend_wx.Toolbar``,
12+
- ``cbook.align_iterators``,
13+
- ``contour.ContourLabeler.get_real_label_width``,
14+
- ``legend.Legend.draggable``,
15+
- ``texmanager.TexManager.postscriptd``, ``texmanager.TexManager.pscnt``,
16+
``texmanager.TexManager.make_ps``, ``texmanager.TexManager.get_ps_bbox``,
17+
- the ``normed`` kwarg to ``Axes.hist``,
18+
- the ``fig`` kwarg to ``GridSpec.get_subplot_params`` and
19+
``GridSpecFromSubplotSpec.get_subplot_params``,
20+
- svgfont support (in :rc:`svg.fonttype`),
21+
- passing 'box-forced' to `axes.Axes.set_adjustable`,

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: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6295,8 +6295,7 @@ def table(self, **kwargs):
62956295
def hist(self, x, bins=None, range=None, density=None, weights=None,
62966296
cumulative=False, bottom=None, histtype='bar', align='mid',
62976297
orientation='vertical', rwidth=None, log=False,
6298-
color=None, label=None, stacked=False, normed=None,
6299-
**kwargs):
6298+
color=None, label=None, stacked=False, **kwargs):
63006299
"""
63016300
Plot a histogram.
63026301
@@ -6364,30 +6363,26 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
63646363
number of observations. If *stacked* is also ``True``, the sum of
63656364
the histograms is normalized to 1.
63666365
6367-
Default is ``None`` for both *normed* and *density*. If either is
6368-
set, then that value will be used. If neither are set, then the
6369-
args will be treated as ``False``.
6370-
6371-
If both *density* and *normed* are set an error is raised.
6366+
Default is ``False``.
63726367
63736368
weights : (n, ) array_like or None, optional
6374-
An array of weights, of the same shape as *x*. Each value in *x*
6375-
only contributes its associated weight towards the bin count
6376-
(instead of 1). If *normed* or *density* is ``True``,
6377-
the weights are normalized, so that the integral of the density
6378-
over the range remains 1.
6369+
An array of weights, of the same shape as *x*. Each value in
6370+
*x* only contributes its associated weight towards the bin count
6371+
(instead of 1). If *density* is ``True``, the weights are
6372+
normalized, so that the integral of the density over the range
6373+
remains 1.
63796374
63806375
Default is ``None``
63816376
63826377
cumulative : bool, optional
6383-
If ``True``, then a histogram is computed where each bin gives the
6384-
counts in that bin plus all bins for smaller values. The last bin
6385-
gives the total number of datapoints. If *normed* or *density*
6386-
is also ``True`` then the histogram is normalized such that the
6387-
last bin equals 1. If *cumulative* evaluates to less than 0
6388-
(e.g., -1), the direction of accumulation is reversed.
6389-
In this case, if *normed* and/or *density* is also ``True``, then
6390-
the histogram is normalized such that the first bin equals 1.
6378+
If ``True``, then a histogram is computed where each bin gives
6379+
the counts in that bin plus all bins for smaller values. The last
6380+
bin gives the total number of datapoints. If *density* is also
6381+
``True`` then the histogram is normalized such that the last bin
6382+
equals 1. If *cumulative* evaluates to less than 0 (e.g., -1), the
6383+
direction of accumulation is reversed. In this case, if *density*
6384+
is also ``True``, then the histogram is normalized such that the
6385+
first bin equals 1.
63916386
63926387
Default is ``False``
63936388
@@ -6467,21 +6462,16 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64676462
64686463
Default is ``False``
64696464
6470-
normed : bool, optional
6471-
Deprecated; use the density keyword argument instead.
6472-
64736465
Returns
64746466
-------
64756467
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.
6468+
The values of the histogram bins. See *density* and *weights* for a
6469+
description of the possible semantics. If input *x* is an array,
6470+
then this is an array of length *nbins*. If input is a sequence of
6471+
arrays ``[data1, data2,..]``, then this is a list of arrays with
6472+
the values of the histograms for each of the arrays in the same
6473+
order. The dtype of the array *n* (or of its element arrays) will
6474+
always be float even if no weighting or normalization is used.
64856475
64866476
bins : array
64876477
The edges of the bins. Length nbins + 1 (nbins left edges and right
@@ -6530,15 +6520,6 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
65306520
if histtype == 'barstacked' and not stacked:
65316521
stacked = True
65326522

6533-
if density is not None and normed is not None:
6534-
raise ValueError("kwargs 'density' and 'normed' cannot be used "
6535-
"simultaneously. "
6536-
"Please only use 'density', since 'normed'"
6537-
"is deprecated.")
6538-
if normed is not None:
6539-
cbook.warn_deprecated("2.1", name="'normed'", obj_type="kwarg",
6540-
alternative="'density'", removal="3.1")
6541-
65426523
# basic input validation
65436524
input_empty = np.size(x) == 0
65446525
# Massage 'x' for processing.
@@ -6594,7 +6575,6 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
65946575
xmin = min(xmin, np.nanmin(xi))
65956576
xmax = max(xmax, np.nanmax(xi))
65966577
bin_range = (xmin, xmax)
6597-
density = bool(density) or bool(normed)
65986578
if density and not stacked:
65996579
hist_kwargs = dict(range=bin_range, density=density)
66006580
else:

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,7 @@ def set_adjustable(self, adjustable, share=False):
13221322
which the adjustments for aspect ratios are done sequentially
13231323
and independently on each Axes as it is drawn.
13241324
"""
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'):
1325+
if adjustable not in ('box', 'datalim'):
13291326
raise ValueError("argument must be 'box', or 'datalim'")
13301327
if share:
13311328
axes = set(self._shared_x_axes.get_siblings(self)

lib/matplotlib/axis.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,15 +758,6 @@ def _set_scale(self, value, **kwargs):
758758
def limit_range_for_scale(self, vmin, vmax):
759759
return self._scale.limit_range_for_scale(vmin, vmax, self.get_minpos())
760760

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-
770761
def get_children(self):
771762
children = [self.label, self.offsetText]
772763
majorticks = self.get_major_ticks()

lib/matplotlib/backend_bases.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,34 +1593,6 @@ def is_saving(self):
15931593
"""
15941594
return self._is_saving
15951595

1596-
@cbook.deprecated("2.2")
1597-
def onRemove(self, ev):
1598-
"""
1599-
Mouse event processor which removes the top artist
1600-
under the cursor. Connect this to the 'mouse_press_event'
1601-
using::
1602-
1603-
canvas.mpl_connect('mouse_press_event',canvas.onRemove)
1604-
"""
1605-
# Find the top artist under the cursor
1606-
under = cbook._topmost_artist(self.figure.hitlist(ev))
1607-
h = None
1608-
if under:
1609-
h = under[-1]
1610-
1611-
# Try deleting that artist, or its parent if you
1612-
# can't delete the artist
1613-
while h:
1614-
if h.remove():
1615-
self.draw_idle()
1616-
break
1617-
parent = None
1618-
for p in under:
1619-
if h in p.get_children():
1620-
parent = p
1621-
break
1622-
h = parent
1623-
16241596
def pick(self, mouseevent):
16251597
if not self.widgetlock.locked():
16261598
self.figure.pick(mouseevent)
@@ -2457,10 +2429,6 @@ def key_press(self, event):
24572429
if rcParams['toolbar'] != 'toolmanager':
24582430
key_press_handler(event, self.canvas, self.canvas.toolbar)
24592431

2460-
@cbook.deprecated("2.2")
2461-
def show_popup(self, msg):
2462-
"""Display message in a popup -- GUI only."""
2463-
24642432
def get_window_title(self):
24652433
"""Get the title text of the window containing the figure.
24662434

0 commit comments

Comments
 (0)