symforce.type_helpers module¶
- deduce_input_type(parameter, func, is_first_parameter)[source]¶
Attempt to deduce the type of an input parameter to a function
Strategy: 1) If it’s annotated with something, return that 2) If it’s the first parameter and its name is “self”, search for a type by the class part of
the function’s qualified name
- Parameters:
parameter (
Parameter
) –func (
Callable
) –is_first_parameter (
bool
) –
- Return type:
Union
[Any
,Type
]
- deduce_input_types(func)[source]¶
Attempt to deduce input types from the type annotations on func, to be used by Codegen.function.
See the docstring on deduce_input_type for deduction strategy
- Parameters:
func (
Callable
) –- Return type:
Sequence
[Union
[Any
,Type
]]
- symbolic_inputs(func, input_types=None)[source]¶
Return symbolic arguments for the inputs to func
- Parameters:
func (
Callable
) – A callable; args should have type annotations, and those types should be constructible automatically with StorageOps.symbolicinput_types (
Optional
[Sequence
[Union
[Any
,Type
]]]) –
- Return type:
- Returns:
A tuple with a symbolic object for each input to func
- symbolic_eval(func)[source]¶
Build symbolic arguments for a function, and return the function evaluated on those arguments.
Useful for easily visualizing what expressions a symbolic function produces
- Parameters:
func (
Callable
[…, ~_T]) – A callable; args should have type annotations, and those types should be constructible automatically with StorageOps.symbolic- Return type:
~_T
- Returns:
The outputs of func evaluated on the constructed symbolic args