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

Skip to content

Commit e3d2eb7

Browse files
committed
Expire deprecations
1 parent e8a231e commit e3d2eb7

File tree

4 files changed

+9
-286
lines changed

4 files changed

+9
-286
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
pyparsing_common)
2121

2222
import matplotlib as mpl
23-
from . import _api, cbook
23+
from . import cbook
2424
from ._mathtext_data import (
2525
latex_to_bakoma, stix_glyph_fixes, stix_virtual_fonts, tex2uni)
2626
from .font_manager import FontProperties, findfont, get_font
@@ -35,8 +35,7 @@
3535
# FONTS
3636

3737

38-
@_api.delete_parameter("3.6", "math")
39-
def get_unicode_index(symbol, math=False): # Publicly exported.
38+
def get_unicode_index(symbol): # Publicly exported.
4039
r"""
4140
Return the integer index (from the Unicode table) of *symbol*.
4241
@@ -45,17 +44,7 @@ def get_unicode_index(symbol, math=False): # Publicly exported.
4544
symbol : str
4645
A single (Unicode) character, a TeX command (e.g. r'\pi') or a Type1
4746
symbol name (e.g. 'phi').
48-
math : bool, default: False
49-
If True (deprecated), replace ASCII hyphen-minus by Unicode minus.
5047
"""
51-
# From UTF #25: U+2212 minus sign is the preferred
52-
# representation of the unary and binary minus sign rather than
53-
# the ASCII-derived U+002D hyphen-minus, because minus sign is
54-
# unambiguous and because it is rendered with a more desirable
55-
# length, usually longer than a hyphen.
56-
# Remove this block when the 'math' parameter is deleted.
57-
if math and symbol == '-':
58-
return 0x2212
5948
try: # This will succeed if symbol is a single Unicode char
6049
return ord(symbol)
6150
except TypeError:

lib/matplotlib/axis.py

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,6 @@ def set_clip_path(self, clippath, transform=None):
240240
self.gridline.set_clip_path(clippath, transform)
241241
self.stale = True
242242

243-
@_api.deprecated("3.6")
244-
def get_pad_pixels(self):
245-
return self.figure.dpi * self._base_pad / 72
246-
247243
def contains(self, mouseevent):
248244
"""
249245
Test whether the mouse event occurred in the Tick marks.
@@ -1233,21 +1229,6 @@ def _set_artist_props(self, a):
12331229
return
12341230
a.set_figure(self.figure)
12351231

1236-
@_api.deprecated("3.6")
1237-
def get_ticklabel_extents(self, renderer):
1238-
"""Get the extents of the tick labels on either side of the axes."""
1239-
ticks_to_draw = self._update_ticks()
1240-
tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1241-
if len(tlb1):
1242-
bbox1 = mtransforms.Bbox.union(tlb1)
1243-
else:
1244-
bbox1 = mtransforms.Bbox.from_extents(0, 0, 0, 0)
1245-
if len(tlb2):
1246-
bbox2 = mtransforms.Bbox.union(tlb2)
1247-
else:
1248-
bbox2 = mtransforms.Bbox.from_extents(0, 0, 0, 0)
1249-
return bbox1, bbox2
1250-
12511232
def _update_ticks(self):
12521233
"""
12531234
Update ticks (position and labels) using the current data interval of
@@ -2362,29 +2343,6 @@ def _update_offset_text_position(self, bboxes, bboxes2):
23622343
y = top + self.OFFSETTEXTPAD * self.figure.dpi / 72
23632344
self.offsetText.set_position((x, y))
23642345

2365-
@_api.deprecated("3.6")
2366-
def get_text_heights(self, renderer):
2367-
"""
2368-
Return how much space should be reserved for text above and below the
2369-
Axes, as a pair of floats.
2370-
"""
2371-
bbox, bbox2 = self.get_ticklabel_extents(renderer)
2372-
# MGDTODO: Need a better way to get the pad
2373-
pad_pixels = self.majorTicks[0].get_pad_pixels()
2374-
2375-
above = 0.0
2376-
if bbox2.height:
2377-
above += bbox2.height + pad_pixels
2378-
below = 0.0
2379-
if bbox.height:
2380-
below += bbox.height + pad_pixels
2381-
2382-
if self.get_label_position() == 'top':
2383-
above += self.label.get_window_extent(renderer).height + pad_pixels
2384-
else:
2385-
below += self.label.get_window_extent(renderer).height + pad_pixels
2386-
return above, below
2387-
23882346
def set_ticks_position(self, position):
23892347
"""
23902348
Set the ticks position.
@@ -2627,25 +2585,6 @@ def set_offset_position(self, position):
26272585
self.offsetText.set_position((x, y))
26282586
self.stale = True
26292587

2630-
@_api.deprecated("3.6")
2631-
def get_text_widths(self, renderer):
2632-
bbox, bbox2 = self.get_ticklabel_extents(renderer)
2633-
# MGDTODO: Need a better way to get the pad
2634-
pad_pixels = self.majorTicks[0].get_pad_pixels()
2635-
2636-
left = 0.0
2637-
if bbox.width:
2638-
left += bbox.width + pad_pixels
2639-
right = 0.0
2640-
if bbox2.width:
2641-
right += bbox2.width + pad_pixels
2642-
2643-
if self.get_label_position() == 'left':
2644-
left += self.label.get_window_extent(renderer).width + pad_pixels
2645-
else:
2646-
right += self.label.get_window_extent(renderer).width + pad_pixels
2647-
return left, right
2648-
26492588
def set_ticks_position(self, position):
26502589
"""
26512590
Set the ticks position.

lib/matplotlib/mathtext.py

Lines changed: 1 addition & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
metrics for those fonts.
1616
"""
1717

18-
from collections import namedtuple
1918
import functools
2019
import logging
2120

22-
import numpy as np
23-
24-
import matplotlib as mpl
2521
from matplotlib import _api, _mathtext
26-
from matplotlib.ft2font import FT2Image, LOAD_NO_HINTING
22+
from matplotlib.ft2font import LOAD_NO_HINTING
2723
from matplotlib.font_manager import FontProperties
2824
from ._mathtext import ( # noqa: reexported API
2925
RasterParse, VectorParse, get_unicode_index)
@@ -33,151 +29,6 @@
3329

3430
get_unicode_index.__module__ = __name__
3531

36-
37-
@_api.deprecated("3.6")
38-
class MathtextBackend:
39-
"""
40-
The base class for the mathtext backend-specific code. `MathtextBackend`
41-
subclasses interface between mathtext and specific Matplotlib graphics
42-
backends.
43-
44-
Subclasses need to override the following:
45-
46-
- :meth:`render_glyph`
47-
- :meth:`render_rect_filled`
48-
- :meth:`get_results`
49-
50-
And optionally, if you need to use a FreeType hinting style:
51-
52-
- :meth:`get_hinting_type`
53-
"""
54-
def __init__(self):
55-
self.width = 0
56-
self.height = 0
57-
self.depth = 0
58-
59-
def set_canvas_size(self, w, h, d):
60-
"""Set the dimension of the drawing canvas."""
61-
self.width = w
62-
self.height = h
63-
self.depth = d
64-
65-
def render_glyph(self, ox, oy, info):
66-
"""
67-
Draw a glyph described by *info* to the reference point (*ox*,
68-
*oy*).
69-
"""
70-
raise NotImplementedError()
71-
72-
def render_rect_filled(self, x1, y1, x2, y2):
73-
"""
74-
Draw a filled black rectangle from (*x1*, *y1*) to (*x2*, *y2*).
75-
"""
76-
raise NotImplementedError()
77-
78-
def get_results(self, box):
79-
"""
80-
Return a backend-specific tuple to return to the backend after
81-
all processing is done.
82-
"""
83-
raise NotImplementedError()
84-
85-
def get_hinting_type(self):
86-
"""
87-
Get the FreeType hinting type to use with this particular
88-
backend.
89-
"""
90-
return LOAD_NO_HINTING
91-
92-
93-
@_api.deprecated("3.6")
94-
class MathtextBackendAgg(MathtextBackend):
95-
"""
96-
Render glyphs and rectangles to an FTImage buffer, which is later
97-
transferred to the Agg image by the Agg backend.
98-
"""
99-
def __init__(self):
100-
self.ox = 0
101-
self.oy = 0
102-
self.image = None
103-
self.mode = 'bbox'
104-
self.bbox = [0, 0, 0, 0]
105-
super().__init__()
106-
107-
def _update_bbox(self, x1, y1, x2, y2):
108-
self.bbox = [min(self.bbox[0], x1),
109-
min(self.bbox[1], y1),
110-
max(self.bbox[2], x2),
111-
max(self.bbox[3], y2)]
112-
113-
def set_canvas_size(self, w, h, d):
114-
super().set_canvas_size(w, h, d)
115-
if self.mode != 'bbox':
116-
self.image = FT2Image(np.ceil(w), np.ceil(h + max(d, 0)))
117-
118-
def render_glyph(self, ox, oy, info):
119-
if self.mode == 'bbox':
120-
self._update_bbox(ox + info.metrics.xmin,
121-
oy - info.metrics.ymax,
122-
ox + info.metrics.xmax,
123-
oy - info.metrics.ymin)
124-
else:
125-
info.font.draw_glyph_to_bitmap(
126-
self.image, ox, oy - info.metrics.iceberg, info.glyph,
127-
antialiased=mpl.rcParams['text.antialiased'])
128-
129-
def render_rect_filled(self, x1, y1, x2, y2):
130-
if self.mode == 'bbox':
131-
self._update_bbox(x1, y1, x2, y2)
132-
else:
133-
height = max(int(y2 - y1) - 1, 0)
134-
if height == 0:
135-
center = (y2 + y1) / 2.0
136-
y = int(center - (height + 1) / 2.0)
137-
else:
138-
y = int(y1)
139-
self.image.draw_rect_filled(int(x1), y, np.ceil(x2), y + height)
140-
141-
def get_results(self, box):
142-
self.image = None
143-
self.mode = 'render'
144-
return _mathtext.ship(box).to_raster()
145-
146-
def get_hinting_type(self):
147-
from matplotlib.backends import backend_agg
148-
return backend_agg.get_hinting_flag()
149-
150-
151-
@_api.deprecated("3.6")
152-
class MathtextBackendPath(MathtextBackend):
153-
"""
154-
Store information to write a mathtext rendering to the text path
155-
machinery.
156-
"""
157-
158-
_Result = namedtuple("_Result", "width height depth glyphs rects")
159-
160-
def __init__(self):
161-
super().__init__()
162-
self.glyphs = []
163-
self.rects = []
164-
165-
def render_glyph(self, ox, oy, info):
166-
oy = self.height - oy + info.offset
167-
self.glyphs.append((info.font, info.fontsize, info.num, ox, oy))
168-
169-
def render_rect_filled(self, x1, y1, x2, y2):
170-
self.rects.append((x1, self.height - y2, x2 - x1, y2 - y1))
171-
172-
def get_results(self, box):
173-
return _mathtext.ship(box).to_vector()
174-
175-
176-
@_api.deprecated("3.6")
177-
class MathTextWarning(Warning):
178-
pass
179-
180-
18132
##############################################################################
18233
# MAIN
18334

0 commit comments

Comments
 (0)