Closed
Description
This proposes adding support for computing the element-wise minimum and maximum values when provided two input arrays.
Overview
Based on API comparison data, maximum and minimum APIs are available in all array libraries. And each array library uses the same naming convention: maximum
and minimum
.
Prior art
maximum
- NumPy: https://numpy.org/doc/stable/reference/generated/numpy.maximum.html
- PyTorch: https://pytorch.org/docs/stable/generated/torch.maximum.html
- TensorFlow: https://www.tensorflow.org/api_docs/python/tf/math/maximum
- JAX: https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.maximum.html
- CuPy: https://docs.cupy.dev/en/stable/reference/generated/cupy.maximum.html
- Dask: https://docs.dask.org/en/stable/generated/dask.array.maximum.html
minimum
- NumPy: https://numpy.org/doc/stable/reference/generated/numpy.minimum.html
- PyTorch: https://pytorch.org/docs/stable/generated/torch.minimum.html
- TensorFlow: https://www.tensorflow.org/api_docs/python/tf/math/minimum
- JAX: https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.minimum.html
- CuPy: https://docs.cupy.dev/en/stable/reference/generated/cupy.minimum.html
- Dask: https://docs.dask.org/en/stable/generated/dask.array.minimum.html
Proposal
def maximum(x1: array, x2: array, /)
def minimum(x1: array, x2: array, /)
Note: as in the specified min
and max
, while conforming implementations may support complex number inputs, inequality comparisons of complex numbers is unspecified, and thus implementation-dependent.
Questions
- Is the
min
/minimum
andmax
/maximum
naming distinction clear enough, where the former are reductions and the latter are binary element-wise operations?
Related
- Common APIs across array libraries (1 year later) #187 (comment)
- SciPy usage. A common use case is when computing tolerances for closeness comparisons.
Metadata
Metadata
Assignees
Type
Projects
Status
Stage 1