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

Commitf3b881f

Browse files
authored
Merge pull request#26432 from meeseeksmachine/auto-backport-of-pr-26431-on-v3.7.x
Backport PR#26431 on branch v3.7.x (MNT: Unpin pyparsing, xfail error message tests for pyparsing 3.1.0)
2 parents2ba853d +7f475c5 commitf3b881f

File tree

5 files changed

+59
-65
lines changed

5 files changed

+59
-65
lines changed

‎environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dependencies:
1919
-pillow>=6.2
2020
-pybind11>=2.6.0
2121
-pygobject
22-
-pyparsing!=3.1.0
22+
-pyparsing>=2.3.1
2323
-pyqt
2424
-python-dateutil>=2.1
2525
-setuptools

‎lib/matplotlib/_mathtext.py

Lines changed: 39 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,8 +1802,11 @@ def __init__(self):
18021802
defset_names_and_parse_actions():
18031803
forkey,valinvars(p).items():
18041804
ifnotkey.startswith('_'):
1805-
# Set names on everything -- very useful for debugging
1806-
val.setName(key)
1805+
# Set names on (almost) everything -- very useful for debugging
1806+
# token, placeable, and auto_delim are forward references which
1807+
# are left without names to ensure useful error messages
1808+
ifkeynotin ("token","placeable","auto_delim"):
1809+
val.setName(key)
18071810
# Set actions
18081811
ifhasattr(self,key):
18091812
val.setParseAction(getattr(self,key))
@@ -1840,63 +1843,39 @@ def csnames(group, names):
18401843
p.unknown_symbol=Regex(r"\\[A-Za-z]*")("name")
18411844

18421845
p.font=csnames("font",self._fontnames)
1843-
p.start_group= (
1844-
Optional(r"\math"+oneOf(self._fontnames)("font"))+"{")
1846+
p.start_group=Optional(r"\math"+oneOf(self._fontnames)("font"))+"{"
18451847
p.end_group=Literal("}")
18461848

18471849
p.delim=oneOf(self._delims)
18481850

1849-
set_names_and_parse_actions()# for root definitions.
1850-
18511851
# Mutually recursive definitions. (Minimizing the number of Forward
18521852
# elements is important for speed.)
1853-
p.accent=Forward()
18541853
p.auto_delim=Forward()
1855-
p.binom=Forward()
1856-
p.customspace=Forward()
1857-
p.frac=Forward()
1858-
p.dfrac=Forward()
1859-
p.function=Forward()
1860-
p.genfrac=Forward()
1861-
p.group=Forward()
1862-
p.operatorname=Forward()
1863-
p.overline=Forward()
1864-
p.overset=Forward()
18651854
p.placeable=Forward()
18661855
p.required_group=Forward()
1867-
p.simple=Forward()
18681856
p.optional_group=Forward()
1869-
p.sqrt=Forward()
1870-
p.subsuper=Forward()
18711857
p.token=Forward()
1872-
p.underset=Forward()
18731858

18741859
set_names_and_parse_actions()# for mutually recursive definitions.
18751860

1876-
p.customspace<<=cmd(r"\hspace","{"+p.float_literal("space")+"}")
1861+
p.optional_group<<="{"+ZeroOrMore(p.token)("group")+"}"
1862+
p.required_group<<="{"+OneOrMore(p.token)("group")+"}"
18771863

1878-
p.accent<<= (
1864+
p.customspace=cmd(r"\hspace","{"+p.float_literal("space")+"}")
1865+
1866+
p.accent= (
18791867
csnames("accent", [*self._accent_map,*self._wide_accents])
18801868
-p.placeable("sym"))
18811869

1882-
p.function<<=csnames("name",self._function_names)
1883-
p.operatorname<<=cmd(
1884-
r"\operatorname",
1885-
"{"+ZeroOrMore(p.simple|p.unknown_symbol)("name")+"}")
1870+
p.function=csnames("name",self._function_names)
18861871

1887-
p.group<<=p.start_group+ZeroOrMore(p.token)("group")+p.end_group
1872+
p.group=p.start_group+ZeroOrMore(p.token)("group")+p.end_group
18881873

1889-
p.optional_group<<="{"+ZeroOrMore(p.token)("group")+"}"
1890-
p.required_group<<="{"+OneOrMore(p.token)("group")+"}"
1891-
1892-
p.frac<<=cmd(
1893-
r"\frac",p.required_group("num")+p.required_group("den"))
1894-
p.dfrac<<=cmd(
1895-
r"\dfrac",p.required_group("num")+p.required_group("den"))
1896-
p.binom<<=cmd(
1897-
r"\binom",p.required_group("num")+p.required_group("den"))
1874+
p.frac=cmd(r"\frac",p.required_group("num")+p.required_group("den"))
1875+
p.dfrac=cmd(r"\dfrac",p.required_group("num")+p.required_group("den"))
1876+
p.binom=cmd(r"\binom",p.required_group("num")+p.required_group("den"))
18981877

1899-
p.genfrac<<=cmd(
1878+
p.genfrac=cmd(
19001879
r"\genfrac",
19011880
"{"+Optional(p.delim)("ldelim")+"}"
19021881
+"{"+Optional(p.delim)("rdelim")+"}"
@@ -1905,20 +1884,38 @@ def csnames(group, names):
19051884
+p.required_group("num")
19061885
+p.required_group("den"))
19071886

1908-
p.sqrt<<=cmd(
1887+
p.sqrt=cmd(
19091888
r"\sqrt{value}",
19101889
Optional("["+OneOrMore(NotAny("]")+p.token)("root")+"]")
19111890
+p.required_group("value"))
19121891

1913-
p.overline<<=cmd(r"\overline",p.required_group("body"))
1892+
p.overline=cmd(r"\overline",p.required_group("body"))
19141893

1915-
p.overset<<=cmd(
1894+
p.overset=cmd(
19161895
r"\overset",
19171896
p.optional_group("annotation")+p.optional_group("body"))
1918-
p.underset<<=cmd(
1897+
p.underset=cmd(
19191898
r"\underset",
19201899
p.optional_group("annotation")+p.optional_group("body"))
19211900

1901+
p.subsuper= (
1902+
(Optional(p.placeable)("nucleus")
1903+
+OneOrMore(oneOf(["_","^"])-p.placeable)("subsuper")
1904+
+Regex("'*")("apostrophes"))
1905+
|Regex("'+")("apostrophes")
1906+
| (p.placeable("nucleus")+Regex("'*")("apostrophes"))
1907+
)
1908+
1909+
p.simple=p.space|p.customspace|p.font|p.subsuper
1910+
1911+
p.token<<= (
1912+
p.simple
1913+
|p.auto_delim
1914+
|p.unknown_symbol# Must be last
1915+
)
1916+
1917+
p.operatorname=cmd(r"\operatorname","{"+ZeroOrMore(p.simple)("name")+"}")
1918+
19221919
p.placeable<<= (
19231920
p.accent# Must be before symbol as all accents are symbols
19241921
|p.symbol# Must be second to catch all named symbols and single
@@ -1936,27 +1933,6 @@ def csnames(group, names):
19361933
|p.overline
19371934
)
19381935

1939-
p.simple<<= (
1940-
p.space
1941-
|p.customspace
1942-
|p.font
1943-
|p.subsuper
1944-
)
1945-
1946-
p.subsuper<<= (
1947-
(Optional(p.placeable)("nucleus")
1948-
+OneOrMore(oneOf(["_","^"])-p.placeable)("subsuper")
1949-
+Regex("'*")("apostrophes"))
1950-
|Regex("'+")("apostrophes")
1951-
| (p.placeable("nucleus")+Regex("'*")("apostrophes"))
1952-
)
1953-
1954-
p.token<<= (
1955-
p.simple
1956-
|p.auto_delim
1957-
|p.unknown_symbol# Must be last
1958-
)
1959-
19601936
p.auto_delim<<= (
19611937
r"\left"- (p.delim("left")|Error("Expected a delimiter"))
19621938
+ZeroOrMore(p.simple|p.auto_delim)("mid")

‎lib/matplotlib/tests/test_mathtext.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
fromxml.etreeimportElementTreeasET
77

88
importnumpyasnp
9+
frompackaging.versionimportparseasparse_version
10+
importpyparsing
911
importpytest
1012

13+
1114
importmatplotlibasmpl
1215
frommatplotlib.testing.decoratorsimportcheck_figures_equal,image_comparison
1316
importmatplotlib.pyplotasplt
1417
frommatplotlibimportmathtext,_mathtext
1518

19+
pyparsing_version=parse_version(pyparsing.__version__)
20+
1621

1722
# If test is removed, use None as placeholder
1823
math_tests= [
@@ -270,6 +275,9 @@ def test_fontinfo():
270275
asserttable['version']== (1,0)
271276

272277

278+
# See gh-26152 for more context on this xfail
279+
@pytest.mark.xfail(pyparsing_version.release== (3,1,0),
280+
reason="Error messages are incorrect for this version")
273281
@pytest.mark.parametrize(
274282
'math, msg',
275283
[

‎lib/matplotlib/tests/test_text.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
importnumpyasnp
66
fromnumpy.testingimportassert_almost_equal
7+
frompackaging.versionimportparseasparse_version
8+
importpyparsing
79
importpytest
810

911
importmatplotlibasmpl
@@ -16,6 +18,8 @@
1618
frommatplotlib.testing._markersimportneeds_usetex
1719
frommatplotlib.textimportText
1820

21+
pyparsing_version=parse_version(pyparsing.__version__)
22+
1923

2024
@image_comparison(['font_styles'])
2125
deftest_font_styles():
@@ -809,6 +813,9 @@ def test_unsupported_script(recwarn):
809813
(r"Matplotlib currently does not support Bengali natively.",)])
810814

811815

816+
# See gh-26152 for more information on this xfail
817+
@pytest.mark.xfail(pyparsing_version.release== (3,1,0),
818+
reason="Error messages are incorrect with pyparsing 3.1.0")
812819
deftest_parse_math():
813820
fig,ax=plt.subplots()
814821
ax.text(0,0,r"$ \wrong{math} $",parse_math=False)
@@ -819,6 +826,9 @@ def test_parse_math():
819826
fig.canvas.draw()
820827

821828

829+
# See gh-26152 for more information on this xfail
830+
@pytest.mark.xfail(pyparsing_version.release== (3,1,0),
831+
reason="Error messages are incorrect with pyparsing 3.1.0")
822832
deftest_parse_math_rcparams():
823833
# Default is True
824834
fig,ax=plt.subplots()

‎setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def make_release_tree(self, base_dir, files):
325325
"numpy>=1.20",
326326
"packaging>=20.0",
327327
"pillow>=6.2.0",
328-
"pyparsing>=2.3.1,<3.1",
328+
"pyparsing>=2.3.1",
329329
"python-dateutil>=2.7",
330330
]+ (
331331
# Installing from a git checkout that is not producing a wheel.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp