You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Pyparsing warnings emitted in mathtext #25204
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.
/path/to/python/lib/python3.9/site-packages/matplotlib/_mathtext.py:1871: UserWarning: warn_name_set_on_empty_Forward: setting results name 'sym' on Forward expression that has no contained expression
- p.placeable("sym"))
/path/to/python/lib/python3.9/site-packages/matplotlib/_mathtext.py:1876: UserWarning: warn_ungrouped_named_tokens_in_collection: setting results name 'name' on ZeroOrMore expression collides with 'name' on contained expression
"{" + ZeroOrMore(p.simple | p.unknown_symbol)("name") + "}")
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 either
python -Wdefault test.py
or
PYTHONWARNINGS=default python test.py
The two warnings are triggered by the following lines within matplotlib/_mathtext.py:
where the various attributes on p are instances of pyparsing.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
Thanks for the clear report @jmd-dk. After a couple of false starts (!) I have reproduced this with main:
/home/ruth/git_stuff/matplotlib/lib/matplotlib/_mathtext.py:1880: UserWarning: warn_name_set_on_empty_Forward: setting results name 'sym' on Forward expression that has no contained expression
- p.placeable("sym"))
/home/ruth/git_stuff/matplotlib/lib/matplotlib/_mathtext.py:1885: UserWarning: warn_ungrouped_named_tokens_in_collection: setting results name 'name' on ZeroOrMore expression collides with 'name' on contained expression
"{" + ZeroOrMore(p.simple | p.unknown_symbol)("name") + "}")
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.
just came across the very same problem which made our CI pipeline "red" (as run with python -We) after a matplotlib update - would be great address this issue!
Thanks
Activity
rcomer commentedon Feb 12, 2023
Thanks for the clear report @jmd-dk. After a couple of false starts (!) I have reproduced this with
main:anntzer commentedon Feb 12, 2023
The second warning is fixed by #25200 (which was coincidentally opened just before this bug report :)).
anntzer commentedon Feb 12, 2023
The other warning can be suppressed with
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.
Filter matplotlib-related warnings
Filter matplotlib-related warnings (#2344)
slayoo commentedon Jan 22, 2024
just came across the very same problem which made our CI pipeline "red" (as run with
python -We) after a matplotlib update - would be great address this issue!Thanks
Work around pyparsing diagnostic warnings