"""BulletML numeric expression.
This translates BulletML numeric expressions into Python expressions.
"""BulletML numeric expression.
This translates BulletML numeric expressions into Python expressions.
self.string = expr = str(expr)
repl = lambda match: "params[%d]" % (int(match.group()[1:]) - 1)
expr = re.sub(r"\$\d+", repl, expr.lower())
self.string = expr = str(expr)
repl = lambda match: "params[%d]" % (int(match.group()[1:]) - 1)
expr = re.sub(r"\$\d+", repl, expr.lower())
self._value = int(round(self._value))
def __call__(self, params, rank):
self._value = int(round(self._value))
def __call__(self, params, rank):
if self._value is not None:
return self._value
return int(round(super(INumberDef, self).__call__(params, rank)))
if self._value is not None:
return self._value
return int(round(super(INumberDef, self).__call__(params, rank)))