Evaluatable

class Evaluatable(expression: str, expected_type: Type[EvalT] | Callable[[Any], EvalT], *, file_name: str = '<string>')

An Evaluatable is an expression that can be evaluated with eval(). These allow for the dynamic evaluation of ShapeQueryParameters and other properties used during the execution of ShapeMachine.

When evaluated, a context can be provided that gets passed to the globals() parameter of the eval() function.

Parameters:
  • expression – The expression to be evaluated.

  • expected_type – The expected output type of the expression. This can also be provided as a callable that maps the value outputted by eval() to the expected type.

  • file_name – A file name used when compiling the expression, which can be helpful during error handling and bug fixing (see compile()).

Methods

evaluate

Evaluate this expression.

evaluate(global_context: dict = None) EvalT

Evaluate this expression.

Parameters:

global_context – A dictionary representing globals() when evaluating the expression with eval().