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

Commitd2e4610

Browse files
committed
Deprecate \mathcircled.
It is not a real TeX command and requires workarounds in the build.One can directly use the corresponding unicode characters instead (forwhich \mathcircled is basically a Matplotlib-only shorthand).
1 parent4e746b0 commitd2e4610

File tree

5 files changed

+41
-14
lines changed

5 files changed

+41
-14
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Deprecations
2+
````````````
3+
4+
The `\mathcircled` mathtext command (which is not a real TeX command)
5+
is deprecated. Directly use unicode characters (e.g.
6+
``"\N{SMALL LATIN CAPITAL LETTER A}"`` or ``"\u24b6"``) instead.
7+
8+
Support for setting:rc:`mathtext.default` to circled is deprecated.

‎examples/text_labels_and_annotations/stix_fonts_demo.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
importmatplotlib.pyplotasplt
99
importnumpyasnp
1010

11+
12+
circle123="\N{CIRCLED DIGIT ONE}\N{CIRCLED DIGIT TWO}\N{CIRCLED DIGIT THREE}"
13+
1114
tests= [
12-
r'$\mathcircled{123} \mathrm{\mathcircled{123}}'
13-
r' \mathbf{\mathcircled{123}}$',
15+
r'$%s \mathrm{%s} \mathbf{%s}$'% ((circle123,)*3),
1416
r'$\mathsf{Sans \Omega} \mathrm{\mathsf{Sans \Omega}}'
1517
r' \mathbf{\mathsf{Sans \Omega}}$',
1618
r'$\mathtt{Monospace}$',
@@ -19,14 +21,12 @@
1921
r'$\mathrm{\mathbb{Blackboard \pi}}$',
2022
r'$\mathbf{\mathbb{Blackboard \pi}}$',
2123
r'$\mathfrak{Fraktur} \mathbf{\mathfrak{Fraktur}}$',
22-
r'$\mathscr{Script}$']
24+
r'$\mathscr{Script}$',
25+
]
2326

2427

25-
plt.figure(figsize=(8, (len(tests)*1)+2))
26-
plt.plot([0,0],'r')
27-
plt.axis([0,3,-len(tests),0])
28-
plt.yticks(-np.arange(len(tests)))
29-
fori,sinenumerate(tests):
30-
plt.text(0.1,-i,s,fontsize=32)
28+
fig=plt.figure(figsize=(8, (len(tests)*1)+2))
29+
fori,sinenumerate(tests[::-1]):
30+
fig.text(0, (i+.5)/len(tests),s,fontsize=32)
3131

3232
plt.show()

‎lib/matplotlib/mathtext.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,6 +2638,11 @@ def font(self):
26382638

26392639
@font.setter
26402640
deffont(self,name):
2641+
ifname=="circled":
2642+
cbook.warn_deprecated(
2643+
"3.1",name="\\mathcircled",obj_type="mathtext command",
2644+
alternative="unicode characters (e.g. '\\N{SMALL LATIN "
2645+
"CAPITAL LETTER A}' or '\\u24b6')")
26412646
ifnamein ('rm','it','bf'):
26422647
self.font_class=name
26432648
self._font=name

‎lib/matplotlib/rcsetup.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,9 +469,19 @@ def validate_font_properties(s):
469469
validate_fontset=ValidateInStrings(
470470
'fontset',
471471
['dejavusans','dejavuserif','cm','stix','stixsans','custom'])
472-
validate_mathtext_default=ValidateInStrings(
473-
'default',
474-
"rm cal it tt sf bf default bb frak circled scr regular".split())
472+
473+
474+
defvalidate_mathtext_default(s):
475+
ifs=="circled":
476+
cbook.warn_deprecated(
477+
"3.1",message="Support for setting the mathtext.default rcParam "
478+
"to 'circled' is deprecated since %(since)s and will be removed "
479+
"%(removal)s.")
480+
returnValidateInStrings(
481+
'default',
482+
"rm cal it tt sf bf default bb frak circled scr regular".split())(s)
483+
484+
475485
validate_verbose=ValidateInStrings(
476486
'verbose',
477487
['silent','helpful','debug','debug-annoying'])

‎lib/matplotlib/tests/test_mathtext.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,18 @@ def baseline_images(request, fontset, index):
163163
return ['%s_%s_%02d'% (request.param,fontset,index)]
164164

165165

166+
# In the following two tests, use recwarn to suppress warnings regarding the
167+
# deprecation of \stackrel and \mathcircled.
168+
169+
166170
@pytest.mark.parametrize('index, test',enumerate(math_tests),
167171
ids=[str(index)forindexinrange(len(math_tests))])
168172
@pytest.mark.parametrize('fontset',
169173
['cm','stix','stixsans','dejavusans',
170174
'dejavuserif'])
171175
@pytest.mark.parametrize('baseline_images', ['mathtext'],indirect=True)
172176
@image_comparison(baseline_images=None)
173-
deftest_mathtext_rendering(baseline_images,fontset,index,test):
177+
deftest_mathtext_rendering(baseline_images,fontset,index,test,recwarn):
174178
matplotlib.rcParams['mathtext.fontset']=fontset
175179
fig=plt.figure(figsize=(5.25,0.75))
176180
fig.text(0.5,0.5,test,
@@ -184,7 +188,7 @@ def test_mathtext_rendering(baseline_images, fontset, index, test):
184188
'dejavuserif'])
185189
@pytest.mark.parametrize('baseline_images', ['mathfont'],indirect=True)
186190
@image_comparison(baseline_images=None,extensions=['png'])
187-
deftest_mathfont_rendering(baseline_images,fontset,index,test):
191+
deftest_mathfont_rendering(baseline_images,fontset,index,test,recwarn):
188192
matplotlib.rcParams['mathtext.fontset']=fontset
189193
fig=plt.figure(figsize=(5.25,0.75))
190194
fig.text(0.5,0.5,test,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp