concepts.dm.crow.function.CrowFunctionBase#

class CrowFunctionBase[source]#

Bases: Function

Methods

flags([short])

Return the flags of the function.

from_function(function[, implementation, sig])

Create a function object from an actual Python function.

get_overridden_call([ftype_index])

Get the overridden call function.

get_sub_function(ftype_index)

mark_static([flag])

Mark a predicate as static (i.e., its grounded value will never change).

partial(*args[, execute_fully_bound_functions])

remap_arguments(remapping)

Generate a new Function object with a different argument order.

set_function_body(function_body)

Set the function body.

set_function_name(function_name)

Set the function name.

Attributes

all_sub_functions

arguments

is_feature

Whether the object is defined as a state feature.

is_function

Whether the object is defined as a function.

is_generator_function

is_overloaded

Return True if the function is overloaded.

nr_arguments

return_type

is_static

Whether the function is static (i.e., its grounded value will never change).

is_cacheable

Whether the function can be cached.

__call__(*args, **kwargs)#

Call self as a function.

__init__(name, ftype, derived_expression=None)[source]#
Parameters:
  • name (str) – the name of the function.

  • ftype (FunctionType) – the function type.

  • derived_expression (ValueOutputExpression | None) – the expression that this function is derived from.

  • overridden_call – the overridden call function.

  • resolved_from – the record of the function that this function is resolved from. This is used for handling partial evaluation and function specialization (for overloadded functions).

  • function_body – the function body.

__new__(**kwargs)#
flags(short=False)[source]#

Return the flags of the function.

Parameters:

short (bool) –

Return type:

Dict[str, bool]

classmethod from_function(function, implementation=True, sig=None)#

Create a function object from an actual Python function.

Parameters:
  • function (Callable) – The function.

  • implementation (bool) – Whether the function is an implementation. Defaults to True.

  • sig (Signature | None) – The signature of the function. Defaults to None.

get_overridden_call(ftype_index=None)#

Get the overridden call function.

Parameters:

ftype_index (int | None) –

Return type:

Callable | None

get_sub_function(ftype_index)#
Parameters:

ftype_index (int) –

Return type:

Function

mark_static(flag=True)[source]#

Mark a predicate as static (i.e., its grounded value will never change).

Parameters:

flag (bool) – Whether to mark the predicate as static.

partial(*args, execute_fully_bound_functions=False, **kwargs)#
Return type:

Function | FunctionApplicationExpression

remap_arguments(remapping)#

Generate a new Function object with a different argument order. Specifically, remapping is a permutation. The i-th argument to the new function will be the remapping[i]-th argument in the old function.

Parameters:

remapping (List[int]) – The remapping.

Returns:

The new function.

Return type:

Function

set_function_body(function_body)#

Set the function body.

Parameters:

function_body (Callable) –

set_function_name(function_name)#

Set the function name.

Parameters:

function_name (str) –

property all_sub_functions#
property arguments: Tuple[Variable]#
is_cacheable: bool#

Whether the function can be cached. Specifically, if it contains only “ObjectTypes” as arguments, it can be statically evaluated.

property is_feature: bool#

Whether the object is defined as a state feature.

property is_function: bool#

Whether the object is defined as a function.

property is_generator_function: bool#
property is_overloaded: bool#

Return True if the function is overloaded.

is_static: bool#

Whether the function is static (i.e., its grounded value will never change).

property nr_arguments: int#
property return_type: ObjectType | ValueType | FunctionType | SequenceType#