MCPcopy
hub / github.com/google/earthengine-api / __init__

Method __init__

python/ee/customfunction.py:26–49  ·  view source on GitHub ↗

Creates a function defined by a given expression with unbound variables. The expression is created by evaluating the given function using variables as placeholders. Args: signature: The function signature. If any of the argument names are null, their names will be gener

(self, signature: dict[str, Any], body: Any)

Source from the content-addressed store, hash-verified

24 _signature: dict[str, Any]
25
26 def __init__(self, signature: dict[str, Any], body: Any):
27 """Creates a function defined by a given expression with unbound variables.
28
29 The expression is created by evaluating the given function
30 using variables as placeholders.
31
32 Args:
33 signature: The function signature. If any of the argument names are
34 null, their names will be generated deterministically, based on
35 the body.
36 body: The Python function to evaluate.
37 """
38 variables = [CustomFunction.variable(arg['type'], arg['name'])
39 for arg in signature['args']]
40
41 if body(*variables) is None:
42 raise ee_exception.EEException('User-defined methods must return a value')
43
44 # The signature of the function.
45 self._signature = CustomFunction._resolveNamelessArgs(
46 signature, variables, body)
47
48 # The expression to evaluate.
49 self._body = body(*variables)
50
51 def encode(self, encoder: Callable[[Any], Any]) -> dict[str, Any]:
52 return {

Callers

nothing calls this directly

Calls 2

variableMethod · 0.80
_resolveNamelessArgsMethod · 0.80

Tested by

no test coverage detected