Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
stewartboogert authored Dec 7, 2024
2 parents b242a68 + 4aace5e commit 326ddfb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pyg4ometry/gdml/Defines.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numbers as _numbers
import numpy as _np
import re as _re
from . import Units as _Units


Expand Down Expand Up @@ -28,6 +29,10 @@ def __init__(self, name, expressionString, registry):
self.registry = registry

def eval(self):
# short-cut for expressions only having a numeric path
if _re.match(r"-?[0-9]+(?:\.[0-9]+)$", self.expressionString):
return float(self.expressionString)

expressionParser = self.registry.getExpressionParser()
self.parseTree = expressionParser.parse(self.expressionString)
value = expressionParser.evaluate(self.parseTree, self.registry.defineDict)
Expand Down

0 comments on commit 326ddfb

Please sign in to comment.