You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/array_api_stubs/_draft/elementwise_functions.py
+5-3
Original file line number
Diff line number
Diff line change
@@ -824,9 +824,9 @@ def clip(
824
824
x: array
825
825
input array. Should have a real-valued data type.
826
826
min: Optional[Union[int, float, array]]
827
-
lower-bound of the range to which to clamp. If ``None``, no lower bound must be applied. Must be compatible with ``x`` (see :ref:`broadcasting`). Should have a real-valued data type. Default: ``None``.
827
+
lower-bound of the range to which to clamp. If ``None``, no lower bound must be applied. Must be compatible with ``x`` (see :ref:`broadcasting`). Should have the same data type as ``x``. Default: ``None``.
828
828
max: Optional[Union[int, float, array]]
829
-
upper-bound of the range to which to clamp. If ``None``, no upper bound must be applied. Must be compatible with ``x`` (see :ref:`broadcasting`). Should have a real-valued data type. Default: ``None``.
829
+
upper-bound of the range to which to clamp. If ``None``, no upper bound must be applied. Must be compatible with ``x`` (see :ref:`broadcasting`). Should have the same data type as ``x``. Default: ``None``.
830
830
831
831
Returns
832
832
-------
@@ -836,10 +836,12 @@ def clip(
836
836
Notes
837
837
-----
838
838
839
+
- This function is conceptually equivalent to ``maximum(minimum(x, max), min)`` when ``x``, ``min``, and ``max`` have the same data type.
840
+
- For scalar ``min`` and/or ``max``, the scalar values must be converted to zero-dimensional arrays having the same data type as ``x`` prior to broadcasting.
839
841
- If both ``min`` and ``max`` are ``None``, the elements of the returned array must equal the respective elements in ``x``.
840
842
- If a broadcasted element in ``min`` is greater than a corresponding broadcasted element in ``max``, behavior is unspecified and thus implementation-dependent.
841
843
- If ``x`` has an integral data type and a broadcasted element in ``min`` or ``max`` is outside the bounds of the data type of ``x``, behavior is unspecified and thus implementation-dependent.
842
-
- If ``x`` and either ``min`` or ``max`` have different data type kinds (e.g., integer versus floating-point), behavior is unspecified and thus implementation-dependent.
844
+
- If ``x`` and either ``min`` or ``max`` have different data types and/or data type kinds (e.g., integer versus floating-point), behavior is unspecified and thus implementation-dependent.
0 commit comments