(self, pyfunc=np._NoValue, otypes=None, doc=None,
excluded=None, cache=False, signature=None)
| 2283 | array([0., 1., 2.]) |
| 2284 | """ |
| 2285 | def __init__(self, pyfunc=np._NoValue, otypes=None, doc=None, |
| 2286 | excluded=None, cache=False, signature=None): |
| 2287 | |
| 2288 | if (pyfunc != np._NoValue) and (not callable(pyfunc)): |
| 2289 | #Splitting the error message to keep |
| 2290 | #the length below 79 characters. |
| 2291 | part1 = "When used as a decorator, " |
| 2292 | part2 = "only accepts keyword arguments." |
| 2293 | raise TypeError(part1 + part2) |
| 2294 | |
| 2295 | self.pyfunc = pyfunc |
| 2296 | self.cache = cache |
| 2297 | self.signature = signature |
| 2298 | if pyfunc != np._NoValue and hasattr(pyfunc, '__name__'): |
| 2299 | self.__name__ = pyfunc.__name__ |
| 2300 | |
| 2301 | self._ufunc = {} # Caching to improve default performance |
| 2302 | self._doc = None |
| 2303 | self.__doc__ = doc |
| 2304 | if doc is None and hasattr(pyfunc, '__doc__'): |
| 2305 | self.__doc__ = pyfunc.__doc__ |
| 2306 | else: |
| 2307 | self._doc = doc |
| 2308 | |
| 2309 | if isinstance(otypes, str): |
| 2310 | for char in otypes: |
| 2311 | if char not in typecodes['All']: |
| 2312 | raise ValueError("Invalid otype specified: %s" % (char,)) |
| 2313 | elif iterable(otypes): |
| 2314 | otypes = ''.join([_nx.dtype(x).char for x in otypes]) |
| 2315 | elif otypes is not None: |
| 2316 | raise ValueError("Invalid otype specification") |
| 2317 | self.otypes = otypes |
| 2318 | |
| 2319 | # Excluded variable support |
| 2320 | if excluded is None: |
| 2321 | excluded = set() |
| 2322 | self.excluded = set(excluded) |
| 2323 | |
| 2324 | if signature is not None: |
| 2325 | self._in_and_out_core_dims = _parse_gufunc_signature(signature) |
| 2326 | else: |
| 2327 | self._in_and_out_core_dims = None |
| 2328 | |
| 2329 | def _init_stage_2(self, pyfunc, *args, **kwargs): |
| 2330 | self.__name__ = pyfunc.__name__ |
nothing calls this directly
no test coverage detected