From 027db58605ca9d33a76c6b91615d2880693823f4 Mon Sep 17 00:00:00 2001 From: Somasree Majumder <56045049+soma2000-lang@users.noreply.github.com> Date: Thu, 16 Feb 2023 19:23:23 +0530 Subject: [PATCH] adding arctan2_ (#10494) Co-authored-by: Vansh Gupta --- ivy/functional/frontends/torch/tensor.py | 5 +++ .../test_frontends/test_torch/test_tensor.py | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/ivy/functional/frontends/torch/tensor.py b/ivy/functional/frontends/torch/tensor.py index 8ce39e5f466bf..70ad4c2a19434 100644 --- a/ivy/functional/frontends/torch/tensor.py +++ b/ivy/functional/frontends/torch/tensor.py @@ -326,6 +326,11 @@ def arctan_(self): def arctan2(self, other): return torch_frontend.arctan2(self._ivy_array, other) + @with_unsupported_dtypes({"1.11.0 and below": ("float16", "bfloat16")}, "torch") + def arctan2_(self, other): + self._ivy_array = self.arctan2(other).ivy_array + return self + @with_unsupported_dtypes({"1.11.0 and below": ("float16",)}, "torch") def acos(self): return torch_frontend.acos(self._ivy_array) diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py index ba0a6b11e989f..2a91b7fe175c8 100644 --- a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py @@ -1726,6 +1726,40 @@ def test_torch_instance_arctan2( ) +# arctan2_ +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="torch.tensor", + method_name="arctan2_", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("float"), + num_arrays=2, + ), +) +def test_torch_instance_arctan2_( + dtype_and_x, + frontend_method_data, + init_flags, + method_flags, + frontend, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_method( + init_input_dtypes=input_dtype, + init_all_as_kwargs_np={ + "data": x[0], + }, + method_input_dtypes=input_dtype, + method_all_as_kwargs_np={ + "other": x[1], + }, + frontend_method_data=frontend_method_data, + init_flags=init_flags, + method_flags=method_flags, + frontend=frontend, + ) + + # acos @handle_frontend_method( class_tree=CLASS_TREE,