A serializable `frompyfunc` object
| 32 | |
| 33 | |
| 34 | class da_frompyfunc: |
| 35 | """A serializable `frompyfunc` object""" |
| 36 | |
| 37 | def __init__(self, func, nin, nout): |
| 38 | self._ufunc = np.frompyfunc(func, nin, nout) |
| 39 | self._func = func |
| 40 | self.nin = nin |
| 41 | self.nout = nout |
| 42 | self._name = funcname(func) |
| 43 | self.__name__ = "frompyfunc-%s" % self._name |
| 44 | |
| 45 | def __repr__(self): |
| 46 | return "da.frompyfunc<%s, %d, %d>" % (self._name, self.nin, self.nout) |
| 47 | |
| 48 | def __dask_tokenize__(self): |
| 49 | return (normalize_token(self._func), self.nin, self.nout) |
| 50 | |
| 51 | def __reduce__(self): |
| 52 | return (da_frompyfunc, (self._func, self.nin, self.nout)) |
| 53 | |
| 54 | def __call__(self, *args, **kwargs): |
| 55 | return self._ufunc(*args, **kwargs) |
| 56 | |
| 57 | def __getattr__(self, a): |
| 58 | if not a.startswith("_"): |
| 59 | return getattr(self._ufunc, a) |
| 60 | raise AttributeError(f"{type(self).__name__!r} object has no attribute {a!r}") |
| 61 | |
| 62 | def __dir__(self): |
| 63 | o = set(dir(type(self))) |
| 64 | o.update(self.__dict__) |
| 65 | o.update(dir(self._ufunc)) |
| 66 | return list(o) |
| 67 | |
| 68 | |
| 69 | @derived_from(np) |
no outgoing calls