MCPcopy Create free account
hub / github.com/numpy/numpy / _call_as_normal

Method _call_as_normal

numpy/lib/function_base.py:2337–2365  ·  view source on GitHub ↗

Return arrays with the results of `pyfunc` broadcast (vectorized) over `args` and `kwargs` not in `excluded`.

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

2335 self.__doc__ = self._doc
2336
2337 def _call_as_normal(self, *args, **kwargs):
2338 """
2339 Return arrays with the results of `pyfunc` broadcast (vectorized) over
2340 `args` and `kwargs` not in `excluded`.
2341 """
2342 excluded = self.excluded
2343 if not kwargs and not excluded:
2344 func = self.pyfunc
2345 vargs = args
2346 else:
2347 # The wrapper accepts only positional arguments: we use `names` and
2348 # `inds` to mutate `the_args` and `kwargs` to pass to the original
2349 # function.
2350 nargs = len(args)
2351
2352 names = [_n for _n in kwargs if _n not in excluded]
2353 inds = [_i for _i in range(nargs) if _i not in excluded]
2354 the_args = list(args)
2355
2356 def func(*vargs):
2357 for _n, _i in enumerate(inds):
2358 the_args[_i] = vargs[_n]
2359 kwargs.update(zip(names, vargs[len(inds):]))
2360 return self.pyfunc(*the_args, **kwargs)
2361
2362 vargs = [args[_i] for _i in inds]
2363 vargs.extend([kwargs[_n] for _n in names])
2364
2365 return self._vectorize_call(func=func, args=vargs)
2366
2367 def __call__(self, *args, **kwargs):
2368 if self.pyfunc is np._NoValue:

Callers 1

__call__Method · 0.95

Calls 1

_vectorize_callMethod · 0.95

Tested by

no test coverage detected