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

Skip to content

Commit 6ab9a74

Browse files
committed
Remove (most) APIs deprecated in mpl2.2.
1 parent 70a55db commit 6ab9a74

23 files changed

+55
-514
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 & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -252,131 +252,6 @@ def _set_logger_verbose_level(level_str='silent', file_str='sys.stdout'):
252252
_log.addHandler(console)
253253

254254

255-
def _parse_commandline():
256-
"""
257-
Check for --verbose-LEVEL type command line arguments and
258-
set logging level appropriately.
259-
"""
260-
261-
levels = ('silent', 'helpful', 'debug', 'debug-annoying',
262-
'info', 'warning')
263-
264-
for arg in sys.argv[1:]:
265-
if arg.startswith('--verbose-'):
266-
level_str = arg[10:]
267-
# If it doesn't match one of ours, then don't even
268-
# bother noting it, we are just a 3rd-party library
269-
# to somebody else's script.
270-
if level_str in levels:
271-
_set_logger_verbose_level(level_str)
272-
273-
_parse_commandline()
274-
275-
276-
class Verbose(object):
277-
"""
278-
A class to handle reporting. Set the fileo attribute to any file
279-
instance to handle the output. Default is sys.stdout
280-
"""
281-
levels = ('silent', 'helpful', 'debug', 'debug-annoying')
282-
vald = {level: i for i, level in enumerate(levels)}
283-
284-
# parse the verbosity from the command line; flags look like
285-
# --verbose-silent or --verbose-helpful
286-
_commandLineVerbose = None
287-
288-
for arg in sys.argv[1:]:
289-
if not arg.startswith('--verbose-'):
290-
continue
291-
level_str = arg[10:]
292-
# If it doesn't match one of ours, then don't even
293-
# bother noting it, we are just a 3rd-party library
294-
# to somebody else's script.
295-
if level_str in levels:
296-
_commandLineVerbose = level_str
297-
298-
@cbook.deprecated("2.2", message=_verbose_msg)
299-
def __init__(self):
300-
self.set_level('silent')
301-
self.fileo = sys.stdout
302-
303-
@cbook.deprecated("2.2", message=_verbose_msg)
304-
def set_level(self, level):
305-
'set the verbosity to one of the Verbose.levels strings'
306-
307-
if self._commandLineVerbose is not None:
308-
level = self._commandLineVerbose
309-
if level not in self.levels:
310-
warnings.warn('matplotlib: unrecognized --verbose-* string "%s".'
311-
' Legal values are %s' % (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-
380255
def _logged_cached(fmt, func=None):
381256
"""
382257
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
@@ -355,25 +355,6 @@ def get_transform(self):
355355
self._transform = self._transform._as_mpl_transform(self.axes)
356356
return self._transform
357357

358-
@cbook.deprecated("2.2")
359-
def hitlist(self, event):
360-
"""
361-
List the children of the artist which contain the mouse event *event*.
362-
"""
363-
L = []
364-
try:
365-
hascursor, info = self.contains(event)
366-
if hascursor:
367-
L.append(self)
368-
except Exception:
369-
import traceback
370-
traceback.print_exc()
371-
print("while checking", self.__class__)
372-
373-
for a in self.get_children():
374-
L.extend(a.hitlist(event))
375-
return L
376-
377358
def get_children(self):
378359
r"""Return a list of the child `.Artist`\s this `.Artist` contains."""
379360
return []
@@ -533,11 +514,6 @@ def get_picker(self):
533514
"""
534515
return self._picker
535516

536-
@cbook.deprecated("2.2", "artist.figure is not None")
537-
def is_figure_set(self):
538-
"""Returns whether the artist is assigned to a `.Figure`."""
539-
return self.figure is not None
540-
541517
def get_url(self):
542518
"""Return the url."""
543519
return self._url

lib/matplotlib/axes/_axes.py

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6255,8 +6255,7 @@ def table(self, **kwargs):
62556255
def hist(self, x, bins=None, range=None, density=None, weights=None,
62566256
cumulative=False, bottom=None, histtype='bar', align='mid',
62576257
orientation='vertical', rwidth=None, log=False,
6258-
color=None, label=None, stacked=False, normed=None,
6259-
**kwargs):
6258+
color=None, label=None, stacked=False, **kwargs):
62606259
"""
62616260
Plot a histogram.
62626261
@@ -6324,30 +6323,26 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
63246323
number of observations. If *stacked* is also ``True``, the sum of
63256324
the histograms is normalized to 1.
63266325
6327-
Default is ``None`` for both *normed* and *density*. If either is
6328-
set, then that value will be used. If neither are set, then the
6329-
args will be treated as ``False``.
6330-
6331-
If both *density* and *normed* are set an error is raised.
6326+
Default is ``False``.
63326327
63336328
weights : (n, ) array_like or None, optional
6334-
An array of weights, of the same shape as *x*. Each value in *x*
6335-
only contributes its associated weight towards the bin count
6336-
(instead of 1). If *normed* or *density* is ``True``,
6337-
the weights are normalized, so that the integral of the density
6338-
over the range remains 1.
6329+
An array of weights, of the same shape as *x*. Each value in
6330+
*x* only contributes its associated weight towards the bin count
6331+
(instead of 1). If *density* is ``True``, the weights are
6332+
normalized, so that the integral of the density over the range
6333+
remains 1.
63396334
63406335
Default is ``None``
63416336
63426337
cumulative : bool, optional
6343-
If ``True``, then a histogram is computed where each bin gives the
6344-
counts in that bin plus all bins for smaller values. The last bin
6345-
gives the total number of datapoints. If *normed* or *density*
6346-
is also ``True`` then the histogram is normalized such that the
6347-
last bin equals 1. If *cumulative* evaluates to less than 0
6348-
(e.g., -1), the direction of accumulation is reversed.
6349-
In this case, if *normed* and/or *density* is also ``True``, then
6350-
the histogram is normalized such that the first bin equals 1.
6338+
If ``True``, then a histogram is computed where each bin gives
6339+
the counts in that bin plus all bins for smaller values. The last
6340+
bin gives the total number of datapoints. If *density* is also
6341+
``True`` then the histogram is normalized such that the last bin
6342+
equals 1. If *cumulative* evaluates to less than 0 (e.g., -1), the
6343+
direction of accumulation is reversed. In this case, if *density*
6344+
is also ``True``, then the histogram is normalized such that the
6345+
first bin equals 1.
63516346
63526347
Default is ``False``
63536348
@@ -6427,19 +6422,15 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64276422
64286423
Default is ``False``
64296424
6430-
normed : bool, optional
6431-
Deprecated; use the density keyword argument instead.
6432-
64336425
Returns
64346426
-------
64356427
n : array or list of arrays
6436-
The values of the histogram bins. See *normed* or *density*
6437-
and *weights* for a description of the possible semantics.
6438-
If input *x* is an array, then this is an array of length
6439-
*nbins*. If input is a sequence of arrays
6440-
``[data1, data2,..]``, then this is a list of arrays with
6441-
the values of the histograms for each of the arrays in the
6442-
same order.
6428+
The values of the histogram bins. See *density* and *weights* for a
6429+
description of the possible semantics. If input *x* is an array,
6430+
then this is an array of length *nbins*. If input is a sequence of
6431+
arrays ``[data1, data2,..]``, then this is a list of arrays with
6432+
the values of the histograms for each of the arrays in the same
6433+
order.
64436434
64446435
bins : array
64456436
The edges of the bins. Length nbins + 1 (nbins left edges and right
@@ -6488,15 +6479,6 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
64886479
if histtype == 'barstacked' and not stacked:
64896480
stacked = True
64906481

6491-
if density is not None and normed is not None:
6492-
raise ValueError("kwargs 'density' and 'normed' cannot be used "
6493-
"simultaneously. "
6494-
"Please only use 'density', since 'normed'"
6495-
"is deprecated.")
6496-
if normed is not None:
6497-
cbook.warn_deprecated("2.1", name="'normed'", obj_type="kwarg",
6498-
alternative="'density'", removal="3.1")
6499-
65006482
# basic input validation
65016483
input_empty = np.size(x) == 0
65026484
# Massage 'x' for processing.
@@ -6552,7 +6534,6 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
65526534
xmin = min(xmin, np.nanmin(xi))
65536535
xmax = max(xmax, np.nanmax(xi))
65546536
bin_range = (xmin, xmax)
6555-
density = bool(density) or bool(normed)
65566537
if density and not stacked:
65576538
hist_kwargs = dict(range=bin_range, density=density)
65586539
else:

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,10 +1315,7 @@ def set_adjustable(self, adjustable, share=False):
13151315
which the adjustments for aspect ratios are done sequentially
13161316
and independently on each Axes as it is drawn.
13171317
"""
1318-
if adjustable == 'box-forced':
1319-
cbook.warn_deprecated(
1320-
"2.2", "box-forced", obj_type="keyword argument")
1321-
if adjustable not in ('box', 'datalim', 'box-forced'):
1318+
if adjustable not in ('box', 'datalim'):
13221319
raise ValueError("argument must be 'box', or 'datalim'")
13231320
if share:
13241321
axes = set(self._shared_x_axes.get_siblings(self)

lib/matplotlib/axis.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -774,16 +774,6 @@ def _set_scale(self, value, **kwargs):
774774
def limit_range_for_scale(self, vmin, vmax):
775775
return self._scale.limit_range_for_scale(vmin, vmax, self.get_minpos())
776776

777-
@property
778-
@cbook.deprecated("2.2.0")
779-
def unit_data(self):
780-
return self.units
781-
782-
@unit_data.setter
783-
@cbook.deprecated("2.2.0")
784-
def unit_data(self, unit_data):
785-
self.set_units(unit_data)
786-
787777
def get_children(self):
788778
children = [self.label, self.offsetText]
789779
majorticks = self.get_major_ticks()

lib/matplotlib/backend_bases.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,34 +1642,6 @@ def is_saving(self):
16421642
"""
16431643
return self._is_saving
16441644

1645-
@cbook.deprecated("2.2")
1646-
def onRemove(self, ev):
1647-
"""
1648-
Mouse event processor which removes the top artist
1649-
under the cursor. Connect this to the 'mouse_press_event'
1650-
using::
1651-
1652-
canvas.mpl_connect('mouse_press_event',canvas.onRemove)
1653-
"""
1654-
# Find the top artist under the cursor
1655-
under = cbook._topmost_artist(self.figure.hitlist(ev))
1656-
h = None
1657-
if under:
1658-
h = under[-1]
1659-
1660-
# Try deleting that artist, or its parent if you
1661-
# can't delete the artist
1662-
while h:
1663-
if h.remove():
1664-
self.draw_idle()
1665-
break
1666-
parent = None
1667-
for p in under:
1668-
if h in p.get_children():
1669-
parent = p
1670-
break
1671-
h = parent
1672-
16731645
def pick(self, mouseevent):
16741646
if not self.widgetlock.locked():
16751647
self.figure.pick(mouseevent)
@@ -2498,10 +2470,6 @@ def key_press(self, event):
24982470
if rcParams['toolbar'] != 'toolmanager':
24992471
key_press_handler(event, self.canvas, self.canvas.toolbar)
25002472

2501-
@cbook.deprecated("2.2")
2502-
def show_popup(self, msg):
2503-
"""Display message in a popup -- GUI only."""
2504-
25052473
def get_window_title(self):
25062474
"""Get the title text of the window containing the figure.
25072475

0 commit comments

Comments
 (0)