concepts.dsl.dsl_functions.FunctionType#
- class FunctionType[source]#
Bases:
TypeBase
FunctionType defines the signature of a function.
Methods
Return the value type for assignment.
downcast_compatible
(other[, ...])Check if the type is downcast-compatible with the other type; that is, if this type is a subtype of the other type.
from_annotation
(function[, sig])Create a FunctionType from a function annotation.
long_str
()Return the long string representation of the type.
resolve_args
(*args, **kwargs)Resolve the arguments to the function type.
set_parent_type
(parent_type)Return the short string representation of the type.
Attributes
An optional alias of the type.
The mapping from argument names to argument indices.
Return the typename of the base type.
The element type of the type.
Return whether the type is a multidimensional list type.
Return whether the type is a list type.
Return whether the type is an object type.
Return whether the type is a Python object value type.
Return whether the type is a sequence type.
Return whether the type is a tensor value type.
Return whether the type is a tuple type.
Return whether the type is a value type.
Return the number of arguments.
The parent type of the type.
Return the typename of the parent type.
The (full) typename of the type.
The types of the arguments.
The names of the arguments.
The argument list composed of Variable instances.
The arguments as a dict, as mappings from argument names to argument types.
The return type of the function type.
The name of the return value.
Whether the function is a generator function.
Whether all arguments are not batched-list types.
Whether there is only one return value.
Whether the function is cacheable.
- __init__(arguments, return_type, argument_names=None, return_name=None, is_generator_function=False, alias=None)[source]#
Initialize the function type.
There are four ways to specify the arguments of the function type:
A list of types, in which case the name of each argument is the index of the argument, using the format #{index}.
A list of types as the arguments, and a list of names as the argument_names.
A list of variables, in which case the name of each argument is the name of the variable.
A dictionary of {name: type}, in which case the order of the arguments is the order of the keys.
The return type can be either a single type or a tuple of types (multi-return types).
- Parameters:
arguments (Sequence[ObjectType | ValueType | FunctionType | SequenceType] | Sequence[Variable] | Dict[str, ObjectType | ValueType | FunctionType | SequenceType]) – The arguments of the function type. When it is a list, the name of the arguments will be automatically generated. When it is a dict, the name of the arguments will be the keys of the dict.
return_type (ObjectType | ValueType | FunctionType | SequenceType) – The return type of the function type.
argument_names (Sequence[str] | None) – The names of the arguments.
return_name (str | Sequence[str] | None) – The name of the return value.
is_generator_function (bool) – Whether the function is a generator function.
alias (str | None) – The alias name of the function type.
- __new__(**kwargs)#
- downcast_compatible(other, allow_self_list=False, allow_list=False)#
Check if the type is downcast-compatible with the other type; that is, if this type is a subtype of the other type.
- classmethod from_annotation(function, sig=None)[source]#
Create a FunctionType from a function annotation.
- Parameters:
- Returns:
The function type.
- Return type:
Union[FunctionType, OverloadedFunctionType]
- resolve_args(*args, **kwargs)[source]#
Resolve the arguments to the function type.
If you want to specify a specific “positional” argument by its index, use _{index} as the name of the argument.
- unwrap_alias()#
- argument_types: Tuple[ObjectType | ValueType | FunctionType | SequenceType, ...]#
The types of the arguments.
- arguments_dict: Dict[str, ObjectType | ValueType | FunctionType | SequenceType]#
The arguments as a dict, as mappings from argument names to argument types.
- property arguments_name2index#
The mapping from argument names to argument indices.
- property base_typename#
Return the typename of the base type.
- property nr_constant_arguments#
- property nr_object_arguments#
- property nr_value_arguments#
- property nr_variable_arguments#
- property parent_typename#
Return the typename of the parent type.
- return_type: ObjectType | ValueType | FunctionType | SequenceType#
The return type of the function type.