Skip to content

Commit

Permalink
Merge pull request #29 from uncountableinc/brendan/fix-e
Browse files Browse the repository at this point in the history
Fix case sensitive e for scientific notation
  • Loading branch information
logansnow17 authored May 1, 2023
2 parents 03fbdf8 + 28ccd07 commit 0abd9c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hotxlfp/grammarparser/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@


def t_SCIENTIFIC_NOTATION_E(t):
r'(?<=\d)\s*e\s*(?=\-?\s*?\.?\d)' # Lookahead to not confuse with variables and functions
r'(?<=\d)\s*[eE]\s*(?=\-?\s*?\.?\d)' # Lookahead to not confuse with variables and functions
return t


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="hotxlfp",
version="0.0.11+unc.25",
version="0.0.11+unc.26",
packages=[
"hotxlfp",
"hotxlfp._compat",
Expand Down
6 changes: 6 additions & 0 deletions tests/test_formula_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,5 +396,11 @@ def test_scientific_notation(self):
_test_equation(equation="-2e-1", variables={"a1" : [1.1]}, answer=-0.2)
_test_equation(equation="-2e-.1", variables={"a1" : [1.1]}, answer=-2 * (10 ** (-.1)))


_test_equation(equation="2E2", variables={"a1" : [1.1]}, answer=[200])
_test_equation(equation="2*1E2", variables={"a1" : [1.1]}, answer=[200])
_test_equation(equation="0.2E2", variables={"a1" : [1.1]}, answer=20)
_test_equation(equation="-2E-1", variables={"a1" : [1.1]}, answer=-0.2)

if __name__ == "__main__":
unittest.main()

0 comments on commit 0abd9c3

Please sign in to comment.