From 45ef9da022dab153835ed90f6be8ea9bdcec1add Mon Sep 17 00:00:00 2001 From: Shreyansh Bardia <104841983+ShreyanshBardia@users.noreply.github.com> Date: Fri, 22 Sep 2023 00:00:30 +0530 Subject: [PATCH] fix: setting min and max as default `None` in `ivy.clip` (#23956) --- ivy/data_classes/array/manipulation.py | 4 ++-- ivy/functional/backends/jax/manipulation.py | 2 +- ivy/functional/backends/numpy/manipulation.py | 4 ++-- ivy/functional/backends/paddle/manipulation.py | 4 ++-- ivy/functional/backends/tensorflow/manipulation.py | 4 ++-- ivy/functional/backends/torch/manipulation.py | 4 ++-- ivy/functional/ivy/manipulation.py | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ivy/data_classes/array/manipulation.py b/ivy/data_classes/array/manipulation.py index a315e60b3c5cc..f9055f928ff2f 100644 --- a/ivy/data_classes/array/manipulation.py +++ b/ivy/data_classes/array/manipulation.py @@ -448,8 +448,8 @@ def stack( def clip( self: ivy.Array, - x_min: Union[Number, ivy.Array, ivy.NativeArray], - x_max: Union[Number, ivy.Array, ivy.NativeArray], + x_min: Optional[Union[Number, ivy.Array, ivy.NativeArray]] = None, + x_max: Optional[Union[Number, ivy.Array, ivy.NativeArray]] = None, /, *, out: Optional[ivy.Array] = None, diff --git a/ivy/functional/backends/jax/manipulation.py b/ivy/functional/backends/jax/manipulation.py index aa3324fd38f1b..59d2bd69aa904 100644 --- a/ivy/functional/backends/jax/manipulation.py +++ b/ivy/functional/backends/jax/manipulation.py @@ -203,9 +203,9 @@ def tile( def clip( x: JaxArray, + /, x_min: Optional[Union[Number, JaxArray]] = None, x_max: Optional[Union[Number, JaxArray]] = None, - /, *, out: Optional[JaxArray] = None, ) -> JaxArray: diff --git a/ivy/functional/backends/numpy/manipulation.py b/ivy/functional/backends/numpy/manipulation.py index 09f313caf1369..290feb9d90253 100644 --- a/ivy/functional/backends/numpy/manipulation.py +++ b/ivy/functional/backends/numpy/manipulation.py @@ -261,9 +261,9 @@ def unstack( def clip( x: np.ndarray, - x_min: Union[Number, np.ndarray], - x_max: Union[Number, np.ndarray], /, + x_min: Optional[Union[Number, np.ndarray]] = None, + x_max: Optional[Union[Number, np.ndarray]] = None, *, out: Optional[np.ndarray] = None, ) -> np.ndarray: diff --git a/ivy/functional/backends/paddle/manipulation.py b/ivy/functional/backends/paddle/manipulation.py index bf654b3f253a4..ea2d8d574a6ad 100644 --- a/ivy/functional/backends/paddle/manipulation.py +++ b/ivy/functional/backends/paddle/manipulation.py @@ -438,9 +438,9 @@ def swapaxes( def clip( x: paddle.Tensor, - x_min: Union[Number, paddle.Tensor], - x_max: Union[Number, paddle.Tensor], /, + x_min: Optional[Union[Number, paddle.Tensor]] = None, + x_max: Optional[Union[Number, paddle.Tensor]] = None, *, out: Optional[paddle.Tensor] = None, ) -> paddle.Tensor: diff --git a/ivy/functional/backends/tensorflow/manipulation.py b/ivy/functional/backends/tensorflow/manipulation.py index d2a4eb6c45eca..c5edf1832acff 100644 --- a/ivy/functional/backends/tensorflow/manipulation.py +++ b/ivy/functional/backends/tensorflow/manipulation.py @@ -332,9 +332,9 @@ def swapaxes( @with_unsupported_dtypes({"2.13.0 and below": ("complex",)}, backend_version) def clip( x: Union[tf.Tensor, tf.Variable], - x_min: Union[Number, tf.Tensor, tf.Variable], - x_max: Union[Number, tf.Tensor, tf.Variable], /, + x_min: Optional[Union[Number, tf.Tensor, tf.Variable]] = None, + x_max: Optional[Union[Number, tf.Tensor, tf.Variable]] = None, *, out: Optional[Union[tf.Tensor, tf.Variable]] = None, ) -> Union[tf.Tensor, tf.Variable]: diff --git a/ivy/functional/backends/torch/manipulation.py b/ivy/functional/backends/torch/manipulation.py index b0ea41b614fcf..21e166e9def85 100644 --- a/ivy/functional/backends/torch/manipulation.py +++ b/ivy/functional/backends/torch/manipulation.py @@ -318,9 +318,9 @@ def swapaxes( ) def clip( x: torch.Tensor, - x_min: Union[Number, torch.Tensor], - x_max: Union[Number, torch.Tensor], /, + x_min: Optional[Union[Number, torch.Tensor]] = None, + x_max: Optional[Union[Number, torch.Tensor]] = None, *, out: Optional[torch.Tensor] = None, ) -> torch.Tensor: diff --git a/ivy/functional/ivy/manipulation.py b/ivy/functional/ivy/manipulation.py index d379fc91f1136..fe6bc5df87f82 100644 --- a/ivy/functional/ivy/manipulation.py +++ b/ivy/functional/ivy/manipulation.py @@ -863,9 +863,9 @@ def stack( @handle_device_shifting def clip( x: Union[ivy.Array, ivy.NativeArray], - x_min: Union[Number, ivy.Array, ivy.NativeArray], - x_max: Union[Number, ivy.Array, ivy.NativeArray], /, + x_min: Optional[Union[Number, ivy.Array, ivy.NativeArray]] = None, + x_max: Optional[Union[Number, ivy.Array, ivy.NativeArray]] = None, *, out: Optional[ivy.Array] = None, ) -> ivy.Array: