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

Skip to content

Commit d624571

Browse files
authored
Merge pull request #22107 from oscargus/mathtext36
Expire mathttext-related deprecations
2 parents 80d4e23 + 08d76e0 commit d624571

File tree

11 files changed

+60
-380
lines changed

11 files changed

+60
-380
lines changed

doc/api/mathtext_api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
:members:
1010
:undoc-members:
1111
:show-inheritance:
12-
:exclude-members: Box, Char, ComputerModernFontConstants, DejaVuSansFontConstants, DejaVuSerifFontConstants, FontConstantsBase, Fonts, Glue, Kern, Node, Parser, STIXFontConstants, STIXSansFontConstants, Ship, StandardPsFonts, TruetypeFonts
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Removal of deprecated ``mathtext`` APIs
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The following `matplotlib.mathtext` APIs have been removed:
5+
- ``Fonts`` and all its subclasses,
6+
- ``FontConstantsBase`` and all its subclasses,
7+
- ``Node`` and all its subclasses,
8+
- ``Ship``, ``ship``,
9+
- ``Error``,
10+
- ``Parser``,
11+
- ``SHRINK_FACTOR``, ``GROW_FACTOR``,
12+
- ``NUM_SIZE_LEVELS``,
13+
- ``latex_to_bakoma``, ``latex_to_cmex``, ``latex_to_standard``,
14+
- ``stix_virtual_fonts``,
15+
- ``tex2uni``
16+
17+
Removal of various ``mathtext`` helpers
18+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19+
20+
The following `matplotlib.mathtext` classes:
21+
- ``MathtextBackendPdf``,
22+
- ``MathtextBackendPs``,
23+
- ``MathtextBackendSvg``,
24+
- ``MathtextBackendCairo``,
25+
and the ``.mathtext_parser`` attributes on
26+
- `.RendererPdf`,
27+
- `.RendererPS`,
28+
- `.RendererSVG`,
29+
- `.RendererCairo`
30+
have been removed. The `.MathtextBackendPath` class can be used instead.
31+
32+
The methods ``get_depth``, ``parse``, ``to_mask``, ``to_rgba``, and ``to_png``
33+
of `.MathTextParser` have been removed. Use `.mathtext.math_to_image` instead.
34+
35+
The unused ``StandardPsFonts.pswriter`` has been removed.
36+
37+
``ps.useafm`` removed for ``mathtext``
38+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39+
40+
The setting :rc:`ps.useafm` no longer has any effect on `matplotlib.mathtext`.

doc/sphinxext/math_symbol_table.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from docutils.parsers.rst import Directive
22

3-
from matplotlib import mathtext
3+
from matplotlib import _mathtext, _mathtext_data
44

55

66
symbols = [
@@ -103,9 +103,9 @@ def run(state_machine):
103103
def render_symbol(sym):
104104
if sym.startswith("\\"):
105105
sym = sym[1:]
106-
if sym not in {*mathtext.Parser._overunder_functions,
107-
*mathtext.Parser._function_names}:
108-
sym = chr(mathtext.tex2uni[sym])
106+
if sym not in (_mathtext.Parser._overunder_functions |
107+
_mathtext.Parser._function_names):
108+
sym = chr(_mathtext_data.tex2uni[sym])
109109
return f'\\{sym}' if sym in ('\\', '|') else sym
110110

111111
lines = []
@@ -149,7 +149,6 @@ def setup(app):
149149

150150
if __name__ == "__main__":
151151
# Do some verification of the tables
152-
from matplotlib import _mathtext_data
153152

154153
print("SYMBOLS NOT IN STIX:")
155154
all_symbols = {}

lib/matplotlib/_mathtext.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from collections import namedtuple
66
import enum
77
import functools
8-
from io import StringIO
98
import logging
109
import os
1110
import types
@@ -92,14 +91,6 @@ def __init__(self, default_font_prop, mathtext_backend):
9291
self.mathtext_backend = mathtext_backend
9392
self.used_characters = {}
9493

95-
@_api.deprecated("3.4")
96-
def destroy(self):
97-
"""
98-
Fix any cyclical references before the object is about
99-
to be destroyed.
100-
"""
101-
self.used_characters = None
102-
10394
def get_kern(self, font1, fontclass1, sym1, fontsize1,
10495
font2, fontclass2, sym2, fontsize2, dpi):
10596
"""
@@ -203,11 +194,6 @@ def get_results(self, box):
203194
"""
204195
result = self.mathtext_backend.get_results(
205196
box, self.get_used_characters())
206-
if self.destroy != TruetypeFonts.destroy.__get__(self):
207-
destroy = _api.deprecate_method_override(
208-
__class__.destroy, self, since="3.4")
209-
if destroy:
210-
destroy()
211197
return result
212198

213199
def get_sized_alternatives_for_symbol(self, fontname, sym):
@@ -235,11 +221,6 @@ def __init__(self, default_font_prop, mathtext_backend):
235221
self._fonts['default'] = default_font
236222
self._fonts['regular'] = default_font
237223

238-
@_api.deprecated("3.4")
239-
def destroy(self):
240-
self.glyphd = None
241-
super().destroy()
242-
243224
def _get_font(self, font):
244225
if font in self.fontmap:
245226
basename = self.fontmap[font]
@@ -803,8 +784,6 @@ def __init__(self, default_font_prop, mathtext_backend=None):
803784
self.fonts['default'] = default_font
804785
self.fonts['regular'] = default_font
805786

806-
pswriter = _api.deprecated("3.4")(property(lambda self: StringIO()))
807-
808787
def _get_font(self, font):
809788
if font in self.fontmap:
810789
basename = self.fontmap[font]

lib/matplotlib/backends/_backend_pdf_ps.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
104104
s, fontsize, renderer=self)
105105
return w, h, d
106106
elif ismath:
107-
# Circular import.
108-
from matplotlib.backends.backend_ps import RendererPS
109-
parse = self._text2path.mathtext_parser.parse(
110-
s, 72, prop,
111-
_force_standard_ps_fonts=(isinstance(self, RendererPS)
112-
and mpl.rcParams["ps.useafm"]))
107+
parse = self._text2path.mathtext_parser.parse(s, 72, prop)
113108
return parse.width, parse.height, parse.depth
114109
elif mpl.rcParams[self._use_afm_rc_name]:
115110
font = self._get_font_afm(prop)

lib/matplotlib/backends/backend_cairo.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
_Backend, FigureCanvasBase, FigureManagerBase, GraphicsContextBase,
3232
RendererBase)
3333
from matplotlib.font_manager import ttfFontProperty
34-
from matplotlib.mathtext import MathTextParser
3534
from matplotlib.path import Path
3635
from matplotlib.transforms import Affine2D
3736

@@ -123,9 +122,6 @@ def attr(field):
123122

124123

125124
class RendererCairo(RendererBase):
126-
mathtext_parser = _api.deprecated("3.4")(
127-
property(lambda self: MathTextParser('Cairo')))
128-
129125
def __init__(self, dpi):
130126
self.dpi = dpi
131127
self.gc = GraphicsContextCairo(renderer=self)

lib/matplotlib/backends/backend_pdf.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import matplotlib.dviread as dviread
4040
from matplotlib.ft2font import (FIXED_WIDTH, ITALIC, LOAD_NO_SCALE,
4141
LOAD_NO_HINTING, KERNING_UNFITTED, FT2Font)
42-
from matplotlib.mathtext import MathTextParser
4342
from matplotlib.transforms import Affine2D, BboxBase
4443
from matplotlib.path import Path
4544
from matplotlib.dates import UTC
@@ -1900,11 +1899,6 @@ def __init__(self, file, image_dpi, height, width):
19001899
self.gc = self.new_gc()
19011900
self.image_dpi = image_dpi
19021901

1903-
@_api.deprecated("3.4")
1904-
@property
1905-
def mathtext_parser(self):
1906-
return MathTextParser("Pdf")
1907-
19081902
def finalize(self):
19091903
self.file.output(*self.gc.finalize())
19101904

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
from enum import Enum
88
import functools
99
import glob
10-
from io import StringIO, TextIOWrapper
10+
from io import StringIO
1111
import logging
1212
import math
1313
import os
1414
import pathlib
15-
import tempfile
1615
import re
1716
import shutil
1817
from tempfile import TemporaryDirectory
@@ -30,7 +29,6 @@
3029
from matplotlib.font_manager import get_font
3130
from matplotlib.ft2font import LOAD_NO_HINTING, LOAD_NO_SCALE, FT2Font
3231
from matplotlib._ttconv import convert_ttf_to_ps
33-
from matplotlib.mathtext import MathTextParser
3432
from matplotlib._mathtext_data import uni2type1
3533
from matplotlib.path import Path
3634
from matplotlib.texmanager import TexManager
@@ -263,9 +261,6 @@ class RendererPS(_backend_pdf_ps.RendererPDFPSBase):
263261
_afm_font_dir = cbook._get_data_path("fonts/afm")
264262
_use_afm_rc_name = "ps.useafm"
265263

266-
mathtext_parser = _api.deprecated("3.4")(property(
267-
lambda self: MathTextParser("PS")))
268-
269264
def __init__(self, width, height, pswriter, imagedpi=72):
270265
# Although postscript itself is dpi independent, we need to inform the
271266
# image code about a requested dpi to generate high resolution images
@@ -689,9 +684,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
689684
def draw_mathtext(self, gc, x, y, s, prop, angle):
690685
"""Draw the math text using matplotlib.mathtext."""
691686
width, height, descent, glyphs, rects = \
692-
self._text2path.mathtext_parser.parse(
693-
s, 72, prop,
694-
_force_standard_ps_fonts=mpl.rcParams["ps.useafm"])
687+
self._text2path.mathtext_parser.parse(s, 72, prop)
695688
self.set_color(*gc.get_rgb())
696689
self._pswriter.write(
697690
f"gsave\n"

lib/matplotlib/backends/backend_svg.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from matplotlib.backends.backend_mixed import MixedModeRenderer
2121
from matplotlib.colors import rgb2hex
2222
from matplotlib.dates import UTC
23-
from matplotlib.mathtext import MathTextParser
2423
from matplotlib.path import Path
2524
from matplotlib import _path
2625
from matplotlib.transforms import Affine2D, Affine2DBase
@@ -318,11 +317,6 @@ def __init__(self, width, height, svgwriter, basename=None, image_dpi=72,
318317
self._write_metadata(metadata)
319318
self._write_default_style()
320319

321-
@_api.deprecated("3.4")
322-
@property
323-
def mathtext_parser(self):
324-
return MathTextParser('SVG')
325-
326320
def finalize(self):
327321
self._write_clips()
328322
self._write_hatches()

0 commit comments

Comments
 (0)