Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcec36cd

Browse files
committed
Deprecate \stackrel.
Mathtext's \stackrel{a}{b} behaves subtly differently from latex's\stackrel{a}{b}: mathtext makes `a` and `b` equal-sized whereas latexmakes `a` smaller than `b` (`a` is an "annotation" over `b`). Giventhat we can already stack expressions using the (admittedly lesspractical, but standard) \genfrac, just deprecate \stackrel instead ofmaintaining our own latex-like dialect.Also undeprecate passing obj_type to the cbook.deprecated decorator(!),given that this PR has a good reason to use it... and while we're at it,reorder the kwargs docs for cbook.deprecated and cbook.warn_deprecatedto match the order in the signature.
1 parent13629a4 commitcec36cd

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Deprecations
2+
````````````
3+
4+
The ``\stackrel`` mathtext command is deprecated (it behaved differently
5+
from LaTeX's ``\stackrel``. To stack two mathtext expressions, use
6+
``\genfrac{left-delim}{right-delim}{fraction-bar-thickness}{}{top}{bottom}``.
7+
8+
Undeprecations
9+
``````````````
10+
11+
The ``obj_type`` kwarg to the ``cbook.deprecated`` decorator is undeprecated.

‎examples/text_labels_and_annotations/mathtext_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
r"\alpha_{i+1}^j = {\rm sin}(2\pi f_j t_i) e^{-5 t_i/\tau},\ "
3535
r"\ldots$",
3636

37-
2:r"$\frac{3}{4},\ \binom{3}{4},\ \stackrel{3}{4},\ "
37+
2:r"$\frac{3}{4},\ \binom{3}{4},\ \genfrac{}{}{0}{}{3}{4},\ "
3838
r"\left(\frac{5 - \frac{1}{x}}{4}\right),\ \ldots$",
3939

4040
3:r"$\sqrt{2},\ \sqrt[3]{x},\ \ldots$",

‎lib/matplotlib/cbook/deprecation.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ def warn_deprecated(
8282
If True, uses a PendingDeprecationWarning instead of a
8383
DeprecationWarning. Cannot be used together with *removal*.
8484
85-
removal : str, optional
86-
The expected removal version. With the default (an empty string), a
87-
removal version is automatically computed from *since*. Set to other
88-
Falsy values to not schedule a removal date. Cannot be used together
89-
with *pending*.
90-
9185
obj_type : str, optional
9286
The object type being deprecated.
9387
9488
addendum : str, optional
9589
Additional text appended directly to the final message.
9690
91+
removal : str, optional
92+
The expected removal version. With the default (an empty string), a
93+
removal version is automatically computed from *since*. Set to other
94+
Falsy values to not schedule a removal date. Cannot be used together
95+
with *pending*.
96+
9797
Examples
9898
--------
9999
@@ -156,15 +156,19 @@ def new_function():
156156
If True, uses a PendingDeprecationWarning instead of a
157157
DeprecationWarning. Cannot be used together with *removal*.
158158
159+
obj_type : str, optional
160+
The object type being deprecated; by default, 'function' if decorating
161+
a function and 'class' if decorating a class.
162+
163+
addendum : str, optional
164+
Additional text appended directly to the final message.
165+
159166
removal : str, optional
160167
The expected removal version. With the default (an empty string), a
161168
removal version is automatically computed from *since*. Set to other
162169
Falsy values to not schedule a removal date. Cannot be used together
163170
with *pending*.
164171
165-
addendum : str, optional
166-
Additional text appended directly to the final message.
167-
168172
Examples
169173
--------
170174
@@ -175,16 +179,10 @@ def the_function_to_deprecate():
175179
pass
176180
"""
177181

178-
ifobj_typeisnotNone:
179-
warn_deprecated(
180-
"3.0","Passing 'obj_type' to the 'deprecated' decorator has no "
181-
"effect, and is deprecated since Matplotlib %(since)s; support "
182-
"for it will be removed %(removal)s.")
183-
184182
defdeprecate(obj,message=message,name=name,alternative=alternative,
185-
pending=pending,addendum=addendum):
183+
pending=pending,obj_type=obj_type,addendum=addendum):
186184
ifisinstance(obj,type):
187-
obj_type="class"
185+
obj_type=obj_typeor"class"
188186
func=obj.__init__
189187
name=nameorobj.__name__
190188
old_doc=obj.__doc__
@@ -195,7 +193,7 @@ def finalize(wrapper, new_doc):
195193
returnobj
196194

197195
elifisinstance(obj,property):
198-
obj_type="attribute"
196+
obj_type=obj_typeor"attribute"
199197
func=None
200198
name=nameorobj.fget.__name__
201199
old_doc=obj.__doc__
@@ -221,7 +219,7 @@ def finalize(_, new_doc):
221219
fget=obj.fget,fset=obj.fset,fdel=obj.fdel,doc=new_doc)
222220

223221
else:
224-
obj_type="function"
222+
obj_type=obj_typeor"function"
225223
func=obj
226224
name=nameorobj.__name__
227225
old_doc=func.__doc__

‎lib/matplotlib/mathtext.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,6 +3182,8 @@ def dfrac(self, s, loc, toks):
31823182
returnself._genfrac('','',thickness,
31833183
self._math_style_dict['displaystyle'],num,den)
31843184

3185+
@cbook.deprecated("3.1",obj_type="mathtext command",
3186+
alternative=r"\genfrac")
31853187
defstackrel(self,s,loc,toks):
31863188
assertlen(toks)==1
31873189
assertlen(toks[0])==2

‎tutorials/text/mathtext.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,16 @@
8080
-----------------------------------------
8181
8282
Fractions, binomials, and stacked numbers can be created with the
83-
``\frac{}{}``, ``\binom{}{}`` and ``\stackrel{}{}`` commands, respectively::
83+
``\frac{}{}``, ``\binom{}{}`` and ``\genfrac{}{}{}{}{}{}`` commands,
84+
respectively::
8485
85-
r'$\frac{3}{4} \binom{3}{4} \stackrel{3}{4}$'
86+
r'$\frac{3}{4} \binom{3}{4} \genfrac{}{}{0}{}{3}{4}$'
8687
8788
produces
8889
8990
.. math::
9091
91-
\frac{3}{4} \binom{3}{4} \stackrel{3}{4}
92+
\frac{3}{4} \binom{3}{4} \genfrac{}{}{0}{}{3}{4}
9293
9394
Fractions can be arbitrarily nested::
9495

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp