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

Method nameArgs

python/ee/function.py:121–165  ·  view source on GitHub ↗

Converts a list of positional arguments to a map of keyword arguments. Uses the function's signature for argument names. Note that this does not check whether the array contains enough arguments to satisfy the call. Args: args: Positional arguments to the function. extra_ke

(
      self,
      args: Sequence[Any],
      extra_keyword_args: dict[str, Any] | None = None,
  )

Source from the content-addressed store, hash-verified

119 return promoted_args
120
121 def nameArgs(
122 self,
123 args: Sequence[Any],
124 extra_keyword_args: dict[str, Any] | None = None,
125 ) -> dict[str, Any]:
126 """Converts a list of positional arguments to a map of keyword arguments.
127
128 Uses the function's signature for argument names. Note that this does not
129 check whether the array contains enough arguments to satisfy the call.
130
131 Args:
132 args: Positional arguments to the function.
133 extra_keyword_args: Optional named arguments to add.
134
135 Returns:
136 Keyword arguments to the function.
137
138 Raises:
139 EEException: If conflicting arguments or too many of them are supplied.
140 """
141 signature = self.getSignature()
142 arg_specs = signature['args']
143
144 # Handle positional arguments.
145 if len(arg_specs) < len(args):
146 raise ee_exception.EEException(
147 'Too many (%d) arguments to function: %s'
148 % (len(args), signature.get('name'))
149 )
150 named_args = {
151 arg_spec['name']: value for arg_spec, value in zip(arg_specs, args)
152 }
153
154 # Handle keyword arguments.
155 if extra_keyword_args:
156 for name in extra_keyword_args:
157 if name in named_args:
158 raise ee_exception.EEException(
159 'Argument %s specified as both positional and '
160 'keyword to function: %s' % (name, signature.get('name'))
161 )
162 named_args[name] = extra_keyword_args[name]
163 # Unrecognized arguments are checked in promoteArgs().
164
165 return named_args
166
167 def getReturnType(self) -> str:
168 return self.getSignature()['returns']

Callers 5

callMethod · 0.95
initFunction · 0.80
test_name_argsMethod · 0.80
function.jsFile · 0.80
targetFunction · 0.80

Calls 2

getSignatureMethod · 0.95
getMethod · 0.45

Tested by 1

test_name_argsMethod · 0.64