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

Function as_gufunc

dask/array/_array_expr/_gufunc.py:754–868  ·  view source on GitHub ↗

Decorator for ``dask.array.gufunc``. Parameters ---------- signature : String Specifies what core dimensions are consumed and produced by ``func``. According to the specification of numpy.gufunc signature [2]_ axes: List of tuples, optional, keyword only

(signature=None, **kwargs)

Source from the content-addressed store, hash-verified

752
753
754def as_gufunc(signature=None, **kwargs):
755 """
756 Decorator for ``dask.array.gufunc``.
757
758 Parameters
759 ----------
760 signature : String
761 Specifies what core dimensions are consumed and produced by ``func``.
762 According to the specification of numpy.gufunc signature [2]_
763 axes: List of tuples, optional, keyword only
764 A list of tuples with indices of axes a generalized ufunc should operate on.
765 For instance, for a signature of ``"(i,j),(j,k)->(i,k)"`` appropriate for
766 matrix multiplication, the base elements are two-dimensional matrices
767 and these are taken to be stored in the two last axes of each argument. The
768 corresponding axes keyword would be ``[(-2, -1), (-2, -1), (-2, -1)]``.
769 For simplicity, for generalized ufuncs that operate on 1-dimensional arrays
770 (vectors), a single integer is accepted instead of a single-element tuple,
771 and for generalized ufuncs for which all outputs are scalars, the output
772 tuples can be omitted.
773 axis: int, optional, keyword only
774 A single axis over which a generalized ufunc should operate. This is a short-cut
775 for ufuncs that operate over a single, shared core dimension, equivalent to passing
776 in axes with entries of (axis,) for each single-core-dimension argument and ``()`` for
777 all others. For instance, for a signature ``"(i),(i)->()"``, it is equivalent to passing
778 in ``axes=[(axis,), (axis,), ()]``.
779 keepdims: bool, optional, keyword only
780 If this is set to True, axes which are reduced over will be left in the result as
781 a dimension with size one, so that the result will broadcast correctly against the
782 inputs. This option can only be used for generalized ufuncs that operate on inputs
783 that all have the same number of core dimensions and with outputs that have no core
784 dimensions , i.e., with signatures like ``"(i),(i)->()"`` or ``"(m,m)->()"``.
785 If used, the location of the dimensions in the output can be controlled with axes
786 and axis.
787 output_dtypes : Optional, dtype or list of dtypes, keyword only
788 Valid numpy dtype specification or list thereof.
789 If not given, a call of ``func`` with a small set of data
790 is performed in order to try to automatically determine the
791 output dtypes.
792 output_sizes : dict, optional, keyword only
793 Optional mapping from dimension names to sizes for outputs. Only used if
794 new core dimensions (not found on inputs) appear on outputs.
795 vectorize: bool, keyword only
796 If set to ``True``, ``np.vectorize`` is applied to ``func`` for
797 convenience. Defaults to ``False``.
798 allow_rechunk: Optional, bool, keyword only
799 Allows rechunking, otherwise chunk sizes need to match and core
800 dimensions are to consist only of one chunk.
801 Warning: enabling this can increase memory usage significantly.
802 Defaults to ``False``.
803 meta: Optional, tuple, keyword only
804 tuple of empty ndarrays describing the shape and dtype of the output of the gufunc.
805 Defaults to ``None``.
806
807 Returns
808 -------
809 Decorator for `pyfunc` that itself returns a `gufunc`.
810
811 Examples

Callers

nothing calls this directly

Calls 1

keysMethod · 0.45

Tested by

no test coverage detected