-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Pyparsing warnings emitted in mathtext #25204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the clear report @jmd-dk. After a couple of false starts (!) I have reproduced this with
|
The second warning is fixed by #25200 (which was coincidentally opened just before this bug report :)). |
The other warning can be suppressed with diff --git i/lib/matplotlib/_mathtext.py w/lib/matplotlib/_mathtext.py
index b41dca9d69..71af0dfdea 100644
--- i/lib/matplotlib/_mathtext.py
+++ w/lib/matplotlib/_mathtext.py
@@ -13,6 +13,7 @@ import types
import unicodedata
import numpy as np
+import pyparsing
from pyparsing import (
Empty, Forward, Literal, NotAny, oneOf, OneOrMore, Optional,
ParseBaseException, ParseException, ParseExpression, ParseFatalException,
@@ -1875,9 +1876,11 @@ class Parser:
p.customspace <<= cmd(r"\hspace", "{" + p.float_literal("space") + "}")
- p.accent <<= (
- csnames("accent", [*self._accent_map, *self._wide_accents])
- - p.placeable("sym"))
+ with cbook._setattr_cm(
+ pyparsing.__diag__, warn_name_set_on_empty_Forward=False):
+ p.accent <<= (
+ csnames("accent", [*self._accent_map, *self._wide_accents])
+ - p.placeable("sym"))
p.function <<= csnames("name", self._function_names)
p.operatorname <<= cmd( but it's not really clear to me whether it's actually warning about a problematic practice or not (one could move the definition of placeable above the one of accent to suppress the warning, but that actually changes the parsing behavior. |
See matplotlib/matplotlib#25244 and matplotlib/matplotlib#25204 Consolidate filterwarnings in pytest.ini
just came across the very same problem which made our CI pipeline "red" (as run with |
Bug summary
When plotting anything with at least one logarithmic axes (
plt.semilogx()
,plt.semilogy()
,plt.loglog()
) I get two warnings emitted due to code in_mathtext.py
. These warnings are not emitted by default, but appears when running Python with e.g.-Wdefault
.Code for reproduction
Actual outcome
Expected outcome
No warnings/text should be printed.
Additional information
To see the warnings from the above code, save it to e.g.
test.py
and run it as eitheror
The two warnings are triggered by the following lines within
matplotlib/_mathtext.py
:where the various attributes on
p
are instances ofpyparsing.Forward
.The warnings appear with Pyparsing versions 3.0.0–3.0.9 but not prior to 3.0.0 (e.g. 2.4.7). Also, the warnings only appear for Matplotlib versions 3.6.0–3.6.3, not e.g. 3.5.3
Operating system
Linux Mint 20
Matplotlib Version
3.6.3
Matplotlib Backend
QtAgg
Python version
3.8.5
Installation
pip
The text was updated successfully, but these errors were encountered: