MCPcopy Index your code
hub / github.com/dask/dask / elemwise

Function elemwise

dask/array/_array_expr/_collection.py:878–930  ·  view source on GitHub ↗

Apply an elementwise ufunc-like function blockwise across arguments. Like numpy ufuncs, broadcasting rules are respected. Parameters ---------- op : callable The function to apply. Should be numpy ufunc-like in the parameters that it accepts. *args : Any

(op, *args, out=None, where=True, dtype=None, name=None, **kwargs)

Source from the content-addressed store, hash-verified

876
877
878def elemwise(op, *args, out=None, where=True, dtype=None, name=None, **kwargs):
879 """Apply an elementwise ufunc-like function blockwise across arguments.
880
881 Like numpy ufuncs, broadcasting rules are respected.
882
883 Parameters
884 ----------
885 op : callable
886 The function to apply. Should be numpy ufunc-like in the parameters
887 that it accepts.
888 *args : Any
889 Arguments to pass to `op`. Non-dask array-like objects are first
890 converted to dask arrays, then all arrays are broadcast together before
891 applying the function blockwise across all arguments. Any scalar
892 arguments are passed as-is following normal numpy ufunc behavior.
893 out : dask array, optional
894 If out is a dask.array then this overwrites the contents of that array
895 with the result.
896 where : array_like, optional
897 An optional boolean mask marking locations where the ufunc should be
898 applied. Can be a scalar, dask array, or any other array-like object.
899 Mirrors the ``where`` argument to numpy ufuncs, see e.g. ``numpy.add``
900 for more information.
901 dtype : dtype, optional
902 If provided, overrides the output array dtype.
903 name : str, optional
904 A unique key name to use when building the backing dask graph. If not
905 provided, one will be automatically generated based on the input
906 arguments.
907
908 Examples
909 --------
910 >>> elemwise(add, x, y) # doctest: +SKIP
911 >>> elemwise(sin, x) # doctest: +SKIP
912 >>> elemwise(sin, x, out=dask_array) # doctest: +SKIP
913
914 See Also
915 --------
916 blockwise
917 """
918 if where is not True:
919 # TODO(expr-soon): Need asarray for this
920 where = True
921
922 if out is not None:
923 raise NotImplementedError("elemwise does not support out=")
924
925 args = [np.asarray(a) if isinstance(a, (list, tuple)) else a for a in args]
926
927 # TODO(expr-soon): We should probably go through blockwise here
928 args = [asanyarray(a) for a in args]
929
930 return new_collection(Elemwise(op, dtype, name, where, *args))
931
932
933def rechunk(

Callers 15

frexpFunction · 0.90
modfFunction · 0.90
__add__Method · 0.70
__radd__Method · 0.70
__mul__Method · 0.70
__rmul__Method · 0.70
__sub__Method · 0.70
__rsub__Method · 0.70
__pow__Method · 0.70
__rpow__Method · 0.70
__truediv__Method · 0.70
__rtruediv__Method · 0.70

Calls 3

new_collectionFunction · 0.90
ElemwiseClass · 0.90
asanyarrayFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…