elemwise¶
- sparse.elemwise(func, *args, **kwargs)[source]¶
Apply a function to any number of arguments.
- Parameters
func (Callable) – The function to apply. Must support broadcasting.
*args (tuple, optional) – The arguments to the function. Can be
SparseArrayobjects orscipy.sparse.spmatrixobjects.**kwargs (dict, optional) – Any additional arguments to pass to the function.
- Returns
The result of applying the function.
- Return type
- Raises
ValueError – If the operation would result in a dense matrix, or if the operands don’t have broadcastable shapes.
See also
numpy.ufuncA similar Numpy construct. Note that any
ufunccan be used as thefuncinput to this function.
Notes
Previously, operations with Numpy arrays were sometimes supported. Now, it is necessary to convert Numpy arrays to
COOobjects.