|
15 | 15 | "bitwise_right_shift",
|
16 | 16 | "bitwise_xor",
|
17 | 17 | "ceil",
|
| 18 | + "clip", |
18 | 19 | "conj",
|
19 | 20 | "copysign",
|
20 | 21 | "cos",
|
|
65 | 66 | ]
|
66 | 67 |
|
67 | 68 |
|
68 |
| -from ._types import array |
| 69 | +from ._types import Optional, Union, array |
69 | 70 |
|
70 | 71 |
|
71 | 72 | def abs(x: array, /) -> array:
|
@@ -775,6 +776,38 @@ def ceil(x: array, /) -> array:
|
775 | 776 | """
|
776 | 777 |
|
777 | 778 |
|
| 779 | +def clip( |
| 780 | + x: array, |
| 781 | + /, |
| 782 | + min: Optional[Union[int, float, array]] = None, |
| 783 | + max: Optional[Union[int, float, array]] = None, |
| 784 | +) -> array: |
| 785 | + r""" |
| 786 | + Clamps each element ``x_i`` of the input array ``x`` to the range ``[min, max]``. |
| 787 | +
|
| 788 | + Parameters |
| 789 | + ---------- |
| 790 | + x: array |
| 791 | + input array. Should have a real-valued data type. |
| 792 | + min: Optional[Union[int, float, array]] |
| 793 | + lower-bound of the range to which to clamp. If ``None``, no lower bound must be applied. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type. Default: ``None``. |
| 794 | + max: Optional[Union[int, float, array]] |
| 795 | + upper-bound of the range to which to clamp. If ``None``, no upper bound must be applied. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued data type. Default: ``None``. |
| 796 | +
|
| 797 | + Returns |
| 798 | + ------- |
| 799 | + out: array |
| 800 | + an array containing element-wise results. The returned array must have the same data type as ``x``. |
| 801 | +
|
| 802 | + Notes |
| 803 | + ----- |
| 804 | +
|
| 805 | + - If both ``min`` and ``max`` are ``None``, the elements of the returned array must equal the respective elements in ``x``. |
| 806 | + - If a broadcasted element in ``min`` is greater than a corresponding broadcasted element in ``max``, behavior is unspecified and thus implementation-dependent. |
| 807 | + - 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. |
| 808 | + """ |
| 809 | + |
| 810 | + |
778 | 811 | def conj(x: array, /) -> array:
|
779 | 812 | """
|
780 | 813 | Returns the complex conjugate for each element ``x_i`` of the input array ``x``.
|
|
0 commit comments