MCPcopy Create free account
hub / github.com/dask/dask / __array_ufunc__

Method __array_ufunc__

dask/dataframe/dask_expr/_collection.py:4209–4232  ·  view source on GitHub ↗
(self, numpy_ufunc, method, *inputs, **kwargs)

Source from the content-addressed store, hash-verified

4207 return new_collection(self.expr.nbytes)
4208
4209 def __array_ufunc__(self, numpy_ufunc, method, *inputs, **kwargs):
4210 out = kwargs.get("out", ())
4211 for x in inputs + out:
4212 # ufuncs work with 0-dimensional NumPy ndarrays
4213 # so we don't want to raise NotImplemented
4214 if isinstance(x, np.ndarray) and x.shape == ():
4215 continue
4216 elif not isinstance(
4217 x, (Number, Scalar, FrameBase, Array, pd.DataFrame, pd.Series, pd.Index)
4218 ):
4219 return NotImplemented
4220
4221 if method == "__call__":
4222 if numpy_ufunc.signature is not None:
4223 return NotImplemented
4224 if numpy_ufunc.nout > 1:
4225 # ufuncs with multiple output values
4226 # are not yet supported for frames
4227 return NotImplemented
4228 else:
4229 return elemwise(numpy_ufunc, *inputs, **kwargs)
4230 else:
4231 # ufunc methods are not yet supported for frames
4232 return NotImplemented
4233
4234 def __array_wrap__(self, array, context=None):
4235 if isinstance(context, tuple) and len(context) > 0:

Callers

nothing calls this directly

Calls 2

elemwiseFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected