Skip to content

Commit

Permalink
handle ident without spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
arun3688 committed Dec 6, 2024
1 parent 6e0b61a commit bfb3e56
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions OMPython/OMTypedParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ def convertTuple(t):
def evaluateExpression(s, loc, toks):
# Convert the tokens (ParseResults) into a string expression
flat_list = [item for sublist in toks[0] for item in sublist]
expr = " ".join(flat_list)
expr = "".join(flat_list)
try:
# Evaluate the expression safely
return eval(expr)
except NameError:
except Exception:
return expr

# Number parsing (supports arithmetic expressions in dimensions) (e.g., {1 + 1, 1})
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ArrayDimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_ArrayDimension(self):
omc.sendExpression("getErrorString()")

result = omc.sendExpression("getComponents(A)")
assert result[-1][-1] == ('y + 1', 10), f"array dimension does not match the expected value. Got: {result[-1][-1]}, Expected: {('y + 1', 10)}"
assert result[-1][-1] == ('y+1', 10), f"array dimension does not match the expected value. Got: {result[-1][-1]}, Expected: {('y+1', 10)}"

omc.__del__()
shutil.rmtree(tempdir, ignore_errors= True)
Expand Down

0 comments on commit bfb3e56

Please sign in to comment.