Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Parser does not recognise form 'nx'

Offen
#2 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
python

Rechercherichtung

Beginne damit, die beiden fehlschlagenden Ausdrücke und ihre funktionierenden n*x-Äquivalente über parseplot.Parser.plot zu reproduzieren, und untersuche dann den im Traceback genannten Einstiegspunkt parse/parser.py sowie den zugrunde liegenden Parsing-Aufruf von plusminus. Als erledigt gilt die Aufgabe, wenn Formen wie 2x und x^3+4x-5 genauso geparst und ausgewertet werden wie ihre Äquivalente mit expliziter Multiplikation.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug enhancement

Parser does not recognise expressions or parts with the form nx where n is an integer/float.
Expressions taking form n*x evaluate fine.

expression 2x:

>>> p = parseplot.Parser('2x')
>>> p.plot(-5, 5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/parseplot/parse/parser.py", line 29, in plot
    xy = (x, self._parser.evaluate(self._function))
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/plusminus/plusminus.py", line 853, in evaluate
    parsed = self.parse(arith_expression, parseAll=True)
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/plusminus/plusminus.py", line 845, in parse
    parsed = self.get_parser().parseString(*args, **kwargs)
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/pyparsing.py", line 1955, in parseString
    raise exc
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/pyparsing.py", line 3814, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected end of text, found 'x'  (at char 1), (line:1, col:2)
>>> p = parseplot.Parser('2*x')
>>> p.plot(-5, 5)
[(-5, -10), (-4, -8), (-3, -6), (-2, -4), (-1, -2), (0, 0), (1, 2), (2, 4), (3, 6), (4, 8), (5, 10)]

expression x^3 + 4x -5

>>> p = parseplot.Parser('x^3+4x-5')
>>> p.plot(-5, 5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/parseplot/parse/parser.py", line 29, in plot
    xy = (x, self._parser.evaluate(self._function))
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/plusminus/plusminus.py", line 853, in evaluate
    parsed = self.parse(arith_expression, parseAll=True)
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/plusminus/plusminus.py", line 845, in parse
    parsed = self.get_parser().parseString(*args, **kwargs)
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/pyparsing.py", line 1955, in parseString
    raise exc
  File "/home/toonarmycaptain/PycharmProjects/parseplot/test_install_env/lib/python3.9/site-packages/pyparsing.py", line 3814, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected end of text, found 'x'  (at char 6), (line:1, col:7)
>>> p = parseplot.Parser('x^3+4*x-5')
>>> p.plot(-5, 5)
[(-5, -150), (-4, -85), (-3, -44), (-2, -21), (-1, -10), (0, -5), (1, 0), (2, 11), (3, 34), (4, 75), (5, 140)]

Vorherrschende Sprache
Python
Sterne
0
Forks
1
Ø Merge
19 Std. 29 Min.
Gemergte PRs (30 T.)
5

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus toonarmycaptain/parseplot

Alle Issues in toonarmycaptain/parseplot

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.