8000 Switch documented deprecations in mathtext by `__getattr__` deprecations · matplotlib/matplotlib@d1689df · GitHub
[go: up one dir, main page]

Skip to content

Commit d1689df

Browse files
committed
Switch documented deprecations in mathtext by __getattr__ deprecations
1 parent b600026 commit d1689df

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

lib/matplotlib/mathtext.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,27 @@
2424
import numpy as np
2525
from PIL import Image
2626

27-
from matplotlib import _api, colors as mcolors, rcParams, _mathtext
27+
from matplotlib import (
28+
_api, colors as mcolors, rcParams, _mathtext, _mathtext_data)
2829
from matplotlib.ft2font import FT2Image, LOAD_NO_HINTING
2930
from matplotlib.font_manager import FontProperties
30-
# Backcompat imports, all are deprecated as of 3.4.
31-
from matplotlib._mathtext import ( # noqa: F401
32-
SHRINK_FACTOR, GROW_FACTOR, NUM_SIZE_LEVELS)
33-
from matplotlib._mathtext_data import ( # noqa: F401
34-
latex_to_bakoma, latex_to_cmex, latex_to_standard, stix_virtual_fonts,
35-
tex2uni)
3631

3732
_log = logging.getLogger(__name__)
3833

3934

35+
@_api.caching_module_getattr
36+
class __getattr__:
37+
locals().update({
38+
name: _api.deprecated("3.4")(
39+
property(lambda self, _mod=mod, _name=name: getattr(_mod, _name)))
40+
for mod, names in [
41+
(_mathtext, ["SHRINK_FACTOR", "GROW_FACTOR", "NUM_SIZE_LEVELS"]),
42+
(_mathtext_data, [
43+
"latex_to_bakoma", "latex_to_cmex", "latex_to_standard",
44+
"stix_virtual_fonts", "tex2uni"])]
45+
for name in names})
46+
47+
4048
get_unicode_index = _mathtext.get_unicode_index
4149
get_unicode_index.__module__ = __name__
4250

0 commit comments

Comments
 (0)
0