COO.elemwise

COO.elemwise(func, *args, **kwargs)[source]

Apply a function to one or two arguments.

Parameters:
  • func (Callable) – The function to apply to one or two arguments.
  • args (tuple, optional) – The extra arguments to pass to the function. If args[0] is a COO object, a scipy.sparse.spmatrix or a scalar; the function will be treated as a binary function. Otherwise, it will be treated as a unary function.
  • kwargs (dict, optional) – The kwargs to pass to the function.
Returns:

The result of applying the function.

Return type:

COO

Raises:

ValueError – If the operation would result in a dense matrix.

See also

numpy.ufunc
A similar Numpy construct. Note that any ufunc can be used as the func input to this function.