From b72acc8843a557e29b284edbf54ec4053485c46f Mon Sep 17 00:00:00 2001 From: danieldaug Date: Sun, 13 Aug 2023 16:27:37 -0700 Subject: [PATCH 01/19] added function paddle.vision.transforms.crop and test draft --- .../frontends/paddle/vision/transforms.py | 8 +++++ .../test_vision/test_transforms.py | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/ivy/functional/frontends/paddle/vision/transforms.py b/ivy/functional/frontends/paddle/vision/transforms.py index 68cb4773981ee..9a99d6b934edc 100644 --- a/ivy/functional/frontends/paddle/vision/transforms.py +++ b/ivy/functional/frontends/paddle/vision/transforms.py @@ -33,3 +33,11 @@ def vflip(img, data_format="CHW"): elif data_format.lower() == "hwc": axis = -3 return ivy.flip(img, axis=axis) + +@with_unsupported_device_and_dtypes( + {"2.5.1 and below": ("float16", "float32", "int16", "int8", "uint8")}, "paddle" +) +@to_ivy_arrays_and_back +def crop(img, top, left, height, width): + array = ivy.array(img) + return array[top:top+height, left:left+width] diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index c22194ace2884..1901ac88da2b9 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -58,3 +58,35 @@ def test_paddle_vflip( img=x[0], backend_to_test=backend_fw, ) + +@handle_frontend_test( + fn_tree="paddle.vision.transforms.crop", + dtype_and_x_and_top_and_left_height_width=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("valid"), + num_arrays=1 + ), +) +def test_paddle_crop( + *, + dtype_and_x_and_top_and_left_and_height_and_width, + on_device, + fn_tree, + frontend, + test_flags, + backend_fw, +): + input_dtype, x_and_top_and_left_height_width = dtype_and_x_and_top_and_left_and_height_and_width + x, top, left, height, width = x_and_top_and_left_height_width + helpers.test_frontend_function( + input_dtypes=input_dtype, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + img=x[0], + top=top, + left=left, + height=height, + width=width, + backend_to_test=backend_fw, + ) From f0550d6fe1a99019e06c67a7bc08e8234982a67c Mon Sep 17 00:00:00 2001 From: yash goel Date: Mon, 14 Aug 2023 19:23:36 +0530 Subject: [PATCH 02/19] add optional get element function --- .../array/experimental/utility.py | 31 +++++++- .../container/experimental/utility.py | 76 ++++++++++++++++++- ivy/functional/ivy/experimental/utility.py | 40 ++++++++++ .../test_core/test_utility.py | 36 +++++++++ 4 files changed, 181 insertions(+), 2 deletions(-) diff --git a/ivy/data_classes/array/experimental/utility.py b/ivy/data_classes/array/experimental/utility.py index 421c007589869..354651e59f9d0 100644 --- a/ivy/data_classes/array/experimental/utility.py +++ b/ivy/data_classes/array/experimental/utility.py @@ -1,6 +1,35 @@ # global +from typing import Optional import abc +# local +import ivy + class _ArrayWithUtilityExperimental(abc.ABC): - pass + def optional_get_element( + self: Optional[ivy.Array] = None, + /, + *, + out: Optional[ivy.Array] = None, + ) -> ivy.Array: + """ + If the input is a tensor or sequence type, it returns the input. + If the input is an optional type, it outputs the element in the input. + It is an error if the input is an empty optional-type (i.e. does not have an element) + and the behavior is undefined in this case. + + Parameters + ---------- + self + Input array + out + Optional output array, for writing the result to. + + Returns + ------- + ret + Input array if it is not None + + """ + return ivy.optional_get_element(self._data, out=out) diff --git a/ivy/data_classes/container/experimental/utility.py b/ivy/data_classes/container/experimental/utility.py index b21273ff50669..0ecfecc098097 100644 --- a/ivy/data_classes/container/experimental/utility.py +++ b/ivy/data_classes/container/experimental/utility.py @@ -1,5 +1,79 @@ +# global +from typing import Optional, Union, Dict, List + +# local +import ivy from ivy.data_classes.container.base import ContainerBase class _ContainerWithUtilityExperimental(ContainerBase): - pass + @staticmethod + def static_optional_get_element( + x: Optional[Union[ivy.Array, ivy.Container]] = None, + /, + *, + key_chains: Optional[Union[List[str], Dict[str, str]]] = None, + to_apply: bool = True, + prune_unapplied: bool = False, + map_sequences: bool = False, + out: Optional[ivy.Container] = None, + ) -> ivy.Container: + """ + ivy.Container static method variant of ivy.optional_get_element. + This method simply wraps the function, and so the docstring for + ivy.optional_get_element also applies to this method + with minimal changes. + Parameters + ---------- + x + container with array inputs. + key_chains + The keychains to apply or not apply the method to. Default is ``None``. + to_apply + If True, the method will be applied to key_chains, otherwise key_chains + will be skipped. Default is ``True``. + prune_unapplied + Whether to prune key_chains for which the function was not applied. + Default is ``False``. + map_sequences + Whether to also map method to sequences (lists, tuples). + Default is ``False``. + out + optional output container, for writing the result to. + Returns + ------- + ret + Container with arrays flattened at leaves. + """ + return ContainerBase.cont_multi_map_in_function( + "optional_get_element", + x, + key_chains=key_chains, + to_apply=to_apply, + prune_unapplied=prune_unapplied, + map_sequences=map_sequences, + out=out, + ) + + def optional_get_element( + self: ivy.Container, + /, + *, + out: Optional[ivy.Container] = None, + ) -> ivy.Container: + """ivy.Container instance method variant of ivy.optional_get_element. + This method simply wraps the function, and so the docstring for + ivy.optional_get_element also applies to this method with minimal + changes. + Parameters + ---------- + self + Input container + out + Optional output container, for writing the result to. + Returns + ------- + ret + Output container. + """ + return self.static_optional_get_element(self, out=out) diff --git a/ivy/functional/ivy/experimental/utility.py b/ivy/functional/ivy/experimental/utility.py index e69de29bb2d1d..57b8b3ec30a4f 100644 --- a/ivy/functional/ivy/experimental/utility.py +++ b/ivy/functional/ivy/experimental/utility.py @@ -0,0 +1,40 @@ +# global +from typing import Optional + +# local +import ivy +from ivy import handle_out_argument, handle_nestable +from ivy.utils.exceptions import handle_exceptions + + +@handle_out_argument +@handle_nestable +@handle_exceptions +def optional_get_element( + x: Optional[ivy.Array] = None, + /, + *, + out: Optional[ivy.Array] = None, +) -> ivy.Array: + """ + If the input is a tensor or sequence type, it returns the input. + If the input is an optional type, it outputs the element in the input. + It is an error if the input is an empty optional-type (i.e. does not have an element) + and the behavior is undefined in this case. + + Parameters + ---------- + x + Input array + out + Optional output array, for writing the result to. + + Returns + ------- + ret + Input array if it is not None + + """ + if x is None: + raise ivy.utils.exceptions.IvyError("The requested optional input has no value.") + return x diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py index e69de29bb2d1d..042bba981f360 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py @@ -0,0 +1,36 @@ +# local +import ivy_tests.test_ivy.helpers as helpers +from ivy_tests.test_ivy.helpers import handle_test + + +@handle_test( + fn_tree="functional.ivy.experimental.optional_get_element", + + dtype_and_x= helpers.dtype_and_values( + min_value=-100, + max_value=100, + min_num_dims=0, + max_num_dims=5, + min_dim_size=0, + max_dim_size=5, + allow_nan= True, + ), +) +def test_optional_get_element( + *, + dtype_and_x, + test_flags, + backend_fw, + fn_name, + on_device, +): + input_dtype, x = dtype_and_x + + helpers.test_function( + input_dtypes=input_dtype, + test_flags=test_flags, + on_device=on_device, + backend_to_test=backend_fw, + fn_name=fn_name, + x=x[0], + ) \ No newline at end of file From 7984976176923b79f4a053607a9a8d626e23c7de Mon Sep 17 00:00:00 2001 From: yash goel Date: Mon, 14 Aug 2023 22:02:28 +0530 Subject: [PATCH 03/19] lint --- .../array/experimental/utility.py | 17 ++++---- .../container/experimental/utility.py | 43 ++++++++++--------- ivy/functional/ivy/experimental/utility.py | 13 +++--- .../test_core/test_utility.py | 23 ++++++++-- 4 files changed, 57 insertions(+), 39 deletions(-) diff --git a/ivy/data_classes/array/experimental/utility.py b/ivy/data_classes/array/experimental/utility.py index 354651e59f9d0..46aaccd3510ad 100644 --- a/ivy/data_classes/array/experimental/utility.py +++ b/ivy/data_classes/array/experimental/utility.py @@ -8,16 +8,16 @@ class _ArrayWithUtilityExperimental(abc.ABC): def optional_get_element( - self: Optional[ivy.Array] = None, - /, - *, - out: Optional[ivy.Array] = None, + self: Optional[ivy.Array] = None, + /, + *, + out: Optional[ivy.Array] = None, ) -> ivy.Array: """ - If the input is a tensor or sequence type, it returns the input. - If the input is an optional type, it outputs the element in the input. - It is an error if the input is an empty optional-type (i.e. does not have an element) - and the behavior is undefined in this case. + If the input is a tensor or sequence type, it returns the input. If the input is + an optional type, it outputs the element in the input. It is an error if the + input is an empty optional-type (i.e. does not have an element) and the behavior + is undefined in this case. Parameters ---------- @@ -30,6 +30,5 @@ def optional_get_element( ------- ret Input array if it is not None - """ return ivy.optional_get_element(self._data, out=out) diff --git a/ivy/data_classes/container/experimental/utility.py b/ivy/data_classes/container/experimental/utility.py index 0ecfecc098097..876a9fad339e5 100644 --- a/ivy/data_classes/container/experimental/utility.py +++ b/ivy/data_classes/container/experimental/utility.py @@ -9,20 +9,20 @@ class _ContainerWithUtilityExperimental(ContainerBase): @staticmethod def static_optional_get_element( - x: Optional[Union[ivy.Array, ivy.Container]] = None, - /, - *, - key_chains: Optional[Union[List[str], Dict[str, str]]] = None, - to_apply: bool = True, - prune_unapplied: bool = False, - map_sequences: bool = False, - out: Optional[ivy.Container] = None, + x: Optional[Union[ivy.Array, ivy.Container]] = None, + /, + *, + key_chains: Optional[Union[List[str], Dict[str, str]]] = None, + to_apply: bool = True, + prune_unapplied: bool = False, + map_sequences: bool = False, + out: Optional[ivy.Container] = None, ) -> ivy.Container: """ - ivy.Container static method variant of ivy.optional_get_element. - This method simply wraps the function, and so the docstring for - ivy.optional_get_element also applies to this method - with minimal changes. + ivy.Container static method variant of ivy.optional_get_element. This method + simply wraps the function, and so the docstring for ivy.optional_get_element + also applies to this method with minimal changes. + Parameters ---------- x @@ -40,6 +40,7 @@ def static_optional_get_element( Default is ``False``. out optional output container, for writing the result to. + Returns ------- ret @@ -56,21 +57,23 @@ def static_optional_get_element( ) def optional_get_element( - self: ivy.Container, - /, - *, - out: Optional[ivy.Container] = None, + self: ivy.Container, + /, + *, + out: Optional[ivy.Container] = None, ) -> ivy.Container: - """ivy.Container instance method variant of ivy.optional_get_element. - This method simply wraps the function, and so the docstring for - ivy.optional_get_element also applies to this method with minimal - changes. + """ + ivy.Container instance method variant of ivy.optional_get_element. This method + simply wraps the function, and so the docstring for ivy.optional_get_element + also applies to this method with minimal changes. + Parameters ---------- self Input container out Optional output container, for writing the result to. + Returns ------- ret diff --git a/ivy/functional/ivy/experimental/utility.py b/ivy/functional/ivy/experimental/utility.py index 57b8b3ec30a4f..e33383151b01c 100644 --- a/ivy/functional/ivy/experimental/utility.py +++ b/ivy/functional/ivy/experimental/utility.py @@ -17,10 +17,10 @@ def optional_get_element( out: Optional[ivy.Array] = None, ) -> ivy.Array: """ - If the input is a tensor or sequence type, it returns the input. - If the input is an optional type, it outputs the element in the input. - It is an error if the input is an empty optional-type (i.e. does not have an element) - and the behavior is undefined in this case. + If the input is a tensor or sequence type, it returns the input. If the input is an + optional type, it outputs the element in the input. It is an error if the input is + an empty optional-type (i.e. does not have an element) and the behavior is undefined + in this case. Parameters ---------- @@ -33,8 +33,9 @@ def optional_get_element( ------- ret Input array if it is not None - """ if x is None: - raise ivy.utils.exceptions.IvyError("The requested optional input has no value.") + raise ivy.utils.exceptions.IvyError( + "The requested optional input has no value." + ) return x diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py index 042bba981f360..128829d4db70f 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py @@ -5,15 +5,30 @@ @handle_test( fn_tree="functional.ivy.experimental.optional_get_element", - - dtype_and_x= helpers.dtype_and_values( + dtype_and_x=helpers.dtype_and_values( + dtype=[ + "int8", + "int16", + "int32", + "int64", + "complex64", + "complex128", + "bool", + "float16", + "float32", + "float64", + "string", + "uint8", + "uint16", + "uint32", + ], min_value=-100, max_value=100, min_num_dims=0, max_num_dims=5, min_dim_size=0, max_dim_size=5, - allow_nan= True, + allow_nan=True, ), ) def test_optional_get_element( @@ -33,4 +48,4 @@ def test_optional_get_element( backend_to_test=backend_fw, fn_name=fn_name, x=x[0], - ) \ No newline at end of file + ) From 3603728546eb76fe8822bda645565d896a932635 Mon Sep 17 00:00:00 2001 From: danieldaug Date: Mon, 14 Aug 2023 19:49:26 -0700 Subject: [PATCH 04/19] simplified crop function and fixed how to get values for crop parameter in testing --- .../frontends/paddle/vision/transforms.py | 3 +-- .../test_vision/test_transforms.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ivy/functional/frontends/paddle/vision/transforms.py b/ivy/functional/frontends/paddle/vision/transforms.py index 2500d357edfb9..6653f486dd055 100644 --- a/ivy/functional/frontends/paddle/vision/transforms.py +++ b/ivy/functional/frontends/paddle/vision/transforms.py @@ -141,5 +141,4 @@ def vflip(img, data_format="CHW"): ) @to_ivy_arrays_and_back def crop(img, top, left, height, width): - array = ivy.array(img) - return array[top:top+height, left:left+width] + return img[top:top+height, left:left+width] diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index a1498b0de4493..25757ed88d401 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -100,22 +100,31 @@ def test_paddle_vflip( @handle_frontend_test( fn_tree="paddle.vision.transforms.crop", - dtype_and_x_and_top_and_left_height_width=helpers.dtype_and_values( + dtype_and_x=helpers.dtype_and_values( available_dtypes=helpers.get_dtypes("valid"), - num_arrays=1 + num_arrays=1, + min_dim_size=2, + max_dim_size=100 ), + top=st.integers(min_value=0, max_value=50), + left=st.integers(min_value=0, max_value=50), + height=st.integers(min_value=0, max_value=50), + width=st.integers(min_value=0, max_value=50), ) def test_paddle_crop( *, - dtype_and_x_and_top_and_left_and_height_and_width, + dtype_and_x, + top, + left, + height, + width, on_device, fn_tree, frontend, test_flags, backend_fw, ): - input_dtype, x_and_top_and_left_height_width = dtype_and_x_and_top_and_left_and_height_and_width - x, top, left, height, width = x_and_top_and_left_height_width + input_dtype, x = dtype_and_x helpers.test_frontend_function( input_dtypes=input_dtype, frontend=frontend, From 487067cc23b991d6494be642309d15e4c815d773 Mon Sep 17 00:00:00 2001 From: danieldaug Date: Tue, 15 Aug 2023 20:08:49 -0700 Subject: [PATCH 05/19] imported necessary information to use st.integers in test_paddle_crop --- .idea/ivy.iml | 2 +- .idea/misc.xml | 2 +- .idea/runConfigurations/_template__of_py_test.xml | 3 +-- .../test_frontends/test_paddle/test_vision/test_transforms.py | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.idea/ivy.iml b/.idea/ivy.iml index 4e727c649cb5b..100e39b8cb102 100644 --- a/.idea/ivy.iml +++ b/.idea/ivy.iml @@ -2,7 +2,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 4d1d4d4ea1dd0..8fa31681b9be4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/.idea/runConfigurations/_template__of_py_test.xml b/.idea/runConfigurations/_template__of_py_test.xml index ad485cdf211d9..77c2d04aa9f4a 100644 --- a/.idea/runConfigurations/_template__of_py_test.xml +++ b/.idea/runConfigurations/_template__of_py_test.xml @@ -8,7 +8,6 @@ + \ No newline at end of file diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index 25757ed88d401..506dd9eabb1ff 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -3,7 +3,7 @@ # local import ivy_tests.test_ivy.helpers as helpers from ivy_tests.test_ivy.helpers import handle_frontend_test - +from hypothesis import strategies as st # to_tensor @handle_frontend_test( From c8fc16efd0ae17c360ded5cc1f0c9c472ddecb2b Mon Sep 17 00:00:00 2001 From: danieldaug Date: Tue, 15 Aug 2023 20:35:22 -0700 Subject: [PATCH 06/19] adjusting min and max values of parameters in test function to see if lint errors are affected --- .../test_paddle/test_vision/test_transforms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index 506dd9eabb1ff..a819189edb876 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -106,10 +106,10 @@ def test_paddle_vflip( min_dim_size=2, max_dim_size=100 ), - top=st.integers(min_value=0, max_value=50), - left=st.integers(min_value=0, max_value=50), - height=st.integers(min_value=0, max_value=50), - width=st.integers(min_value=0, max_value=50), + top=st.integers(min_value=0, max_value=100), + left=st.integers(min_value=0, max_value=100), + height=st.integers(min_value=0, max_value=100), + width=st.integers(min_value=0, max_value=100), ) def test_paddle_crop( *, From 86c3d274b4282ce1ae7ea76e1c7c62864184d4d1 Mon Sep 17 00:00:00 2001 From: danieldaug <127552315+danieldaug@users.noreply.github.com> Date: Wed, 16 Aug 2023 17:26:45 -0700 Subject: [PATCH 07/19] Reverting accidental change to ivy.iml --- .idea/ivy.iml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.idea/ivy.iml b/.idea/ivy.iml index 100e39b8cb102..aad68012bb7a3 100644 --- a/.idea/ivy.iml +++ b/.idea/ivy.iml @@ -2,7 +2,7 @@ - + @@ -12,4 +12,4 @@ - \ No newline at end of file + From 3a3e97583e6efafd86fd7a7e62e744962e5171e5 Mon Sep 17 00:00:00 2001 From: danieldaug <127552315+danieldaug@users.noreply.github.com> Date: Wed, 16 Aug 2023 17:27:28 -0700 Subject: [PATCH 08/19] Reverting accidental change to misc.xml --- .idea/misc.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 8fa31681b9be4..5c0410dbc198c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,8 +3,8 @@ - + - \ No newline at end of file + From f22b36ec013c741e4cff46a68aa035497ca1ac26 Mon Sep 17 00:00:00 2001 From: danieldaug <127552315+danieldaug@users.noreply.github.com> Date: Wed, 16 Aug 2023 17:29:07 -0700 Subject: [PATCH 09/19] Reverting accidental changes to _template__of_py_test.xml --- .idea/runConfigurations/_template__of_py_test.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.idea/runConfigurations/_template__of_py_test.xml b/.idea/runConfigurations/_template__of_py_test.xml index 77c2d04aa9f4a..ad485cdf211d9 100644 --- a/.idea/runConfigurations/_template__of_py_test.xml +++ b/.idea/runConfigurations/_template__of_py_test.xml @@ -8,6 +8,7 @@ \ No newline at end of file + From 320752876508aa585a4baa2d30cf36362d48d951 Mon Sep 17 00:00:00 2001 From: danieldaug Date: Wed, 16 Aug 2023 17:29:49 -0700 Subject: [PATCH 10/19] fixed lint errors --- ivy/functional/frontends/paddle/vision/transforms.py | 2 +- .../test_frontends/test_paddle/test_vision/test_transforms.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ivy/functional/frontends/paddle/vision/transforms.py b/ivy/functional/frontends/paddle/vision/transforms.py index 6653f486dd055..b8c4ce8b826cd 100644 --- a/ivy/functional/frontends/paddle/vision/transforms.py +++ b/ivy/functional/frontends/paddle/vision/transforms.py @@ -141,4 +141,4 @@ def vflip(img, data_format="CHW"): ) @to_ivy_arrays_and_back def crop(img, top, left, height, width): - return img[top:top+height, left:left+width] + return img[top : top + height, left : left + width] diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index a819189edb876..9ac6199e73baf 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -104,7 +104,7 @@ def test_paddle_vflip( available_dtypes=helpers.get_dtypes("valid"), num_arrays=1, min_dim_size=2, - max_dim_size=100 + max_dim_size=100, ), top=st.integers(min_value=0, max_value=100), left=st.integers(min_value=0, max_value=100), From c04fd41fb8d6cde8bbc23e4e5b952415b53a809d Mon Sep 17 00:00:00 2001 From: yash goel Date: Thu, 17 Aug 2023 14:04:34 +0530 Subject: [PATCH 11/19] remove constraints --- .../test_core/test_utility.py | 26 +------------------ 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py index 128829d4db70f..d1215d27ea027 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py @@ -5,31 +5,7 @@ @handle_test( fn_tree="functional.ivy.experimental.optional_get_element", - dtype_and_x=helpers.dtype_and_values( - dtype=[ - "int8", - "int16", - "int32", - "int64", - "complex64", - "complex128", - "bool", - "float16", - "float32", - "float64", - "string", - "uint8", - "uint16", - "uint32", - ], - min_value=-100, - max_value=100, - min_num_dims=0, - max_num_dims=5, - min_dim_size=0, - max_dim_size=5, - allow_nan=True, - ), + dtype_and_x=helpers.dtype_and_values(), ) def test_optional_get_element( *, From 05c0df8afe9f859db63acc65841371b3118b4c3d Mon Sep 17 00:00:00 2001 From: danieldaug Date: Thu, 17 Aug 2023 17:29:52 -0700 Subject: [PATCH 12/19] reorganized code due to odd mix-up of different functions --- .../test_vision/test_transforms.py | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index aef616951d906..38d698ffb902c 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -87,6 +87,7 @@ def test_paddle_vflip( test_flags, backend_fw, ): + input_dtype, x = dtype_and_x helpers.test_frontend_function( input_dtypes=input_dtype, @@ -119,7 +120,26 @@ def test_paddle_crop( left, height, width, -======= + on_device, + fn_tree, + frontend, + test_flags, + backend_fw, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtype, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + img=x[0], + top=top, + left=left, + height=height, + width=width, + backend_to_test=backend_fw, + # hflip @handle_frontend_test( @@ -159,4 +179,4 @@ def test_paddle_hflip( backend_to_test=backend_fw, img=x[0], - ) + ) \ No newline at end of file From 356d133f5665cd93dd739b7fb5bbbf3ffbea2f79 Mon Sep 17 00:00:00 2001 From: danieldaug Date: Thu, 17 Aug 2023 17:36:20 -0700 Subject: [PATCH 13/19] fixed more lint errors after moving other function that was previously mixed up with test_paddle_crop --- .../test_paddle/test_vision/test_transforms.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index 38d698ffb902c..463572ad42de2 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -156,7 +156,6 @@ def test_paddle_crop( def test_paddle_hflip( *, dtype_and_x, - on_device, fn_tree, frontend, @@ -170,13 +169,6 @@ def test_paddle_hflip( test_flags=test_flags, fn_tree=fn_tree, on_device=on_device, - img=x[0], - top=top, - left=left, - height=height, - width=width, - backend_to_test=backend_fw, - backend_to_test=backend_fw, img=x[0], ) \ No newline at end of file From f2d50eefffe07f48cdb1cbd01f3e65777b0dcae4 Mon Sep 17 00:00:00 2001 From: danieldaug Date: Thu, 17 Aug 2023 17:40:33 -0700 Subject: [PATCH 14/19] lint error fix due to missing parenthesis --- .../test_frontends/test_paddle/test_vision/test_transforms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index 463572ad42de2..2cb6d207cce65 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -139,7 +139,7 @@ def test_paddle_crop( height=height, width=width, backend_to_test=backend_fw, - + ) # hflip @handle_frontend_test( @@ -171,4 +171,4 @@ def test_paddle_hflip( on_device=on_device, backend_to_test=backend_fw, img=x[0], - ) \ No newline at end of file + ) From d6ba58292ee80709e3243beb0d61592fa0883487 Mon Sep 17 00:00:00 2001 From: danieldaug Date: Fri, 18 Aug 2023 17:24:47 -0700 Subject: [PATCH 15/19] reverted changes in .idea --- .idea/ivy.iml | 2 +- .idea/misc.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.idea/ivy.iml b/.idea/ivy.iml index aad68012bb7a3..4e727c649cb5b 100644 --- a/.idea/ivy.iml +++ b/.idea/ivy.iml @@ -12,4 +12,4 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 5c0410dbc198c..4d1d4d4ea1dd0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -7,4 +7,4 @@ - + \ No newline at end of file From 564fa30539f3246468cd5189d93c89d3b0066df0 Mon Sep 17 00:00:00 2001 From: yash goel Date: Sat, 19 Aug 2023 15:14:30 +0530 Subject: [PATCH 16/19] retrigger checks From d511aecf6df2a8da2d792b9827c745418b4a3931 Mon Sep 17 00:00:00 2001 From: Kareem Morsy Date: Mon, 21 Aug 2023 15:58:28 +0000 Subject: [PATCH 17/19] Add support for lists in `optional_get_element` --- .../test_experimental/test_core/test_utility.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py index d1215d27ea027..8789c46a529eb 100644 --- a/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py +++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_core/test_utility.py @@ -1,3 +1,6 @@ +# global +from hypothesis import strategies as st + # local import ivy_tests.test_ivy.helpers as helpers from ivy_tests.test_ivy.helpers import handle_test @@ -6,16 +9,19 @@ @handle_test( fn_tree="functional.ivy.experimental.optional_get_element", dtype_and_x=helpers.dtype_and_values(), + input_tensor=st.booleans(), ) def test_optional_get_element( *, dtype_and_x, + input_tensor, test_flags, backend_fw, fn_name, on_device, ): input_dtype, x = dtype_and_x + fn_input = x[0] if input_tensor else x helpers.test_function( input_dtypes=input_dtype, @@ -23,5 +29,5 @@ def test_optional_get_element( on_device=on_device, backend_to_test=backend_fw, fn_name=fn_name, - x=x[0], + x=fn_input, ) From e8d2df9c170c28f48fc4d5f1dd092c660248f04f Mon Sep 17 00:00:00 2001 From: danieldaug Date: Mon, 21 Aug 2023 20:10:55 -0700 Subject: [PATCH 18/19] moved line importing strategies as st into global section --- .../test_frontends/test_paddle/test_vision/test_transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index 2cb6d207cce65..568314781b274 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -1,9 +1,9 @@ # global +from hypothesis import strategies as st # local import ivy_tests.test_ivy.helpers as helpers from ivy_tests.test_ivy.helpers import handle_frontend_test -from hypothesis import strategies as st # to_tensor @handle_frontend_test( From ea7494f5c324405f890a6ce1431ce3285e3753cf Mon Sep 17 00:00:00 2001 From: danieldaug Date: Tue, 22 Aug 2023 18:36:40 -0700 Subject: [PATCH 19/19] attempting to fix line formatting for lint black error --- ivy/functional/frontends/paddle/vision/transforms.py | 1 - ivy_tests/array_api_testing/test_array_api | 2 +- .../test_frontends/test_paddle/test_vision/test_transforms.py | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ivy/functional/frontends/paddle/vision/transforms.py b/ivy/functional/frontends/paddle/vision/transforms.py index f9c052cb25519..b1ba5c8f5ffa5 100644 --- a/ivy/functional/frontends/paddle/vision/transforms.py +++ b/ivy/functional/frontends/paddle/vision/transforms.py @@ -177,4 +177,3 @@ def crop(img, top, left, height, width): def hflip(img): img = ivy.array(img) return ivy.flip(img, axis=-1) - diff --git a/ivy_tests/array_api_testing/test_array_api b/ivy_tests/array_api_testing/test_array_api index 852a1ddfedb14..f82c7bc8627cc 160000 --- a/ivy_tests/array_api_testing/test_array_api +++ b/ivy_tests/array_api_testing/test_array_api @@ -1 +1 @@ -Subproject commit 852a1ddfedb14742ec94a9dfc6b3f3d4e89d0189 +Subproject commit f82c7bc8627cc2c3a44fa3e425f53a253a609aa8 diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py index 43d0e1d2cacd4..e5f2e95737fce 100644 --- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py +++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_vision/test_transforms.py @@ -5,6 +5,7 @@ import ivy_tests.test_ivy.helpers as helpers from ivy_tests.test_ivy.helpers import handle_frontend_test + # to_tensor @handle_frontend_test( fn_tree="paddle.to_tensor", @@ -129,7 +130,6 @@ def test_paddle_vflip( test_flags, backend_fw, ): - input_dtype, x = dtype_and_x helpers.test_frontend_function( input_dtypes=input_dtype, @@ -183,6 +183,7 @@ def test_paddle_crop( backend_to_test=backend_fw, ) + # hflip @handle_frontend_test( fn_tree="paddle.vision.transforms.hflip",