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

Refix for pyparsing compat.#21501

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 1 commit intomatplotlib:mainfromanntzer:p3b
Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletionlib/matplotlib/_mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@
from pyparsing import (
Combine, Empty, FollowedBy, Forward, Group, Literal, oneOf, OneOrMore,
Optional, ParseBaseException, ParseFatalException, ParserElement,
ParseResults, QuotedString, Regex, StringEnd, Suppress, ZeroOrMore)
ParseResults, QuotedString, Regex, StringEnd, Suppress,White,ZeroOrMore)

import matplotlib as mpl
from . import _api, cbook
Expand DownExpand Up@@ -2060,6 +2060,7 @@ def __init__(self):
p.accent <<= Group(
Suppress(p.bslash)
+ oneOf([*self._accent_map, *self._wide_accents])
+ Suppress(Optional(White()))
Copy link

@ptmcgptmcgOct 29, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If the code is not working without this explicit whitespace-skipping, that is a pyparsing bug. Since you have made it Optional, then this won't break once the pyparsing bug is fixed. (You can also - or at leastshould be able to - useEmpty() as a synonym forSuppress(Optional(White()))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ok. Thereis a bug in pyparsing, but fixing it doesn't completely solve your problem.

What is the purpose ofleaveWhitespace() here?

    p.symbol        <<= (p.single_symbol | p.symbol_name).leaveWhitespace()

It looks like this is the only element inp.placeable that suppresses whitespace-skipping. The new code detects this and instead of doing whitespace-skipping before theMatchFirst, it doesn't do whitespace-skipping, relying on all the separate elements to do it themselves (this is the performance optimization - if all the alternatives will want whitespace to be skipped, theMatchFirstwill do it once, and then all the alternatives get a pass). Sincep.symbol suppresses whitespace-skipping, and so makesp.placeable suppress whitespace-skipping, then when it is time to matchp.symbol, the leading space has not been skipped, and so it fails.

So:

  • I need to fix the bug in pyparsing - this will be in 3.0.4, which I will push out this evening.

  • This is another pyparsingimprovement that needs to be documented in the "stuff that has changed for the better, but may affect your code" - I'll add that information in 3.0.4 also.

  • Please revisit why you need to haveleaveWhitespace() onp.symbol.

    If it is required, then I think you could remove theSuppress(Optional(White())) fromp.accent, and instead change thep.symbol usage inp.placeable to:

      | Empty() + p.symbol  # Must be third to catch all named symbols and single

    (I tested this in my minimal repro example and that works.)
    But ideally, you could just remove the call toleaveWhitespace().

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agreed that removing leaveWhitespace seems to work; looking at the git history it seems to be a historical artefact of the times when symbol and symbol_name were not split, and was used for symbol_name.

- p.placeable
)

Expand Down
1 change: 0 additions & 1 deletionrequirements/doc/doc-requirements.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ ipython
ipywidgets
numpydoc>=0.8
packaging>=20
pyparsing<3.0.0
mpl-sphinx-theme
sphinxcontrib-svg2pdfconverter>=1.1.0
sphinx-gallery>=0.10
Expand Down
1 change: 0 additions & 1 deletionrequirements/testing/all.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,6 @@

certifi
coverage
pyparsing<3.0.0
pytest!=4.6.0,!=5.4.0
pytest-cov
pytest-rerunfailures
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp