concepts.dsl.expression.cvt_expression#
- cvt_expression(expr, dtype=None)[source]#
Convert an expression compatible object to an expression. Acceptable types are:
Variable: return aVariableExpression.str: return aConstantExpressionwith the given constant string name, or aObjectConstantExpressionif the dtype is aObjectType.ObjectConstant: return aObjectConstantExpression.bool,int,float,torch.Tensor: return aConstantExpression.ValueBase: return aConstantExpression.
- Parameters:
expr (Expression | Variable | str | ObjectConstant | bool | int | float | Tensor | ValueBase) – the expression compatible object.
dtype (ObjectType | ValueType | None) – the expected data type of the expression. If not given, the dtype will be inferred from the given object.
- Returns:
the converted expression.
- Raises:
TypeError – if the given object is not an expression compatible object.
- Return type: