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

Skip to content

Commit 08d76e0

Browse files
committed
Fixed review comments and a few more removals
1 parent 00ad9c4 commit 08d76e0

File tree

8 files changed

+39
-65
lines changed

8 files changed

+39
-65
lines changed
Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,40 @@
11
Removal of deprecated ``mathtext`` APIs
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

4-
The following :mod:`.mathtext` APIs have been removed:
5-
``MathtextBackendBitmap``,
6-
``MathtextBackendPs``,
7-
``MathtextBackendPdf``,
8-
``MathtextBackendSvg``,
9-
``MathtextBackendCairo``,
10-
``ship``,
11-
``Fonts``,
12-
``TruetypeFonts``,
13-
``StandardPsFonts``,
14-
``FontConstantsBase``,
15-
``ComputerModernFontConstants``,
16-
``STIXFontConstants``,
17-
``STIXSansFontConstants``,
18-
``DejaVuSerifFontConstants``,
19-
``DejaVuSansFontConstants``,
20-
``FontConstantsBase``,
21-
``Node``,
22-
``Box``,
23-
``Char``,
24-
``Glue``,
25-
``Kern``,
26-
``Ship``,
27-
``Parser``,
28-
``SHRINK_FACTOR``,
29-
``GROW_FACTOR``,
30-
``NUM_SIZE_LEVELS``,
31-
``latex_to_bakoma``,
32-
``latex_to_cmex``,
33-
``latex_to_standard``,
34-
``stix_virtual_fonts``, and
35-
``tex2uni``
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``
3616

37-
The methods ``to_mask``, ``to_rgba``, ``to_png``, and ``get_depth`` of
38-
``MathTextParser`` have been removed. Use ``mathtext.math_to_image`` instead.
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.
3936

40-
The named keyword argument ``_force_standard_ps_fonts`` of
41-
``MathTextParser.parse`` has been removed.
37+
``ps.useafm`` removed for ``mathtext``
38+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4239

43-
The following :mod:.`_mathtext` APIs have been removed:
44-
``Fonts.destroy()``, ``TruetypeFonts.destroy()``, and ``StandardPsFonts.pswriter()``
40+
The setting :rc:`ps.useafm` no longer has any effect on `matplotlib.mathtext`.

doc/sphinxext/math_symbol_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def render_symbol(sym):
104104
if sym.startswith("\\"):
105105
sym = sym[1:]
106106
if sym not in (_mathtext.Parser._overunder_functions |
107-
{*_mathtext.Parser._function_names}):
107+
_mathtext.Parser._function_names):
108108
sym = chr(_mathtext_data.tex2uni[sym])
109109
return f'\\{sym}' if sym in ('\\', '|') else sym
110110

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: 1 addition & 6 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

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()

lib/matplotlib/mathtext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
import numpy as np
2323

24-
from matplotlib import (
25-
_api, rcParams, _mathtext)
24+
from matplotlib import _api, rcParams, _mathtext
2625
from matplotlib.ft2font import FT2Image, LOAD_NO_HINTING
2726
from matplotlib.font_manager import FontProperties
2827

lib/matplotlib/tests/test_mathtext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import matplotlib as mpl
1111
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1212
import matplotlib.pyplot as plt
13-
from matplotlib import mathtext
13+
from matplotlib import mathtext, _mathtext
1414

1515

1616
# If test is removed, use None as placeholder
@@ -109,7 +109,7 @@
109109
r'${xyz}^k{x}_{k}{x}^{p}{y}^{p-2} {d}_{i}^{j}{b}_{j}{c}_{k}{d} {x}^{j}_{i}{E}^{0}{E}^0_u$',
110110
r'${\int}_x^x x\oint_x^x x\int_{X}^{X}x\int_x x \int^x x \int_{x} x\int^{x}{\int}_{x} x{\int}^{x}_{x}x$',
111111
r'testing$^{123}$',
112-
None,
112+
' '.join('$\\' + p + '$' for p in sorted(_mathtext.Parser._accentprefixed)),
113113
r'$6-2$; $-2$; $ -2$; ${-2}$; ${ -2}$; $20^{+3}_{-2}$',
114114
r'$\overline{\omega}^x \frac{1}{2}_0^x$', # github issue #5444
115115
r'$,$ $.$ $1{,}234{, }567{ , }890$ and $1,234,567,890$', # github issue 5799

0 commit comments

Comments
 (0)