Repository: ivy-llc/ivy

Issue:
numpy.ndarray.dot



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/ndarray/ndarray.py b/ivy/functional/frontends/numpy/ndarray/ndarray.py
--- a/ivy/functional/frontends/numpy/ndarray/ndarray.py
+++ b/ivy/functional/frontends/numpy/ndarray/ndarray.py
@@ -260,6 +260,9 @@ def cumsum(self, *, axis=None, dtype=None, out=None):
             out=out,
         )
 
+    def dot(self, b, out=None):
+        return np_frontend.dot(self, b, out=out)
+
     def diagonal(self, *, offset=0, axis1=0, axis2=1):
         return np_frontend.diagonal(
             self,


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/helpers.py b/ivy_tests/test_ivy/test_frontends/test_numpy/helpers.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/helpers.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/helpers.py
@@ -265,3 +265,32 @@ def get_num_positional_args_ufunc(draw, *, fn_name=None):
     nin = func.nin
     nargs = func.nargs
     return draw(st.integers(min_value=nin, max_value=nargs))
+
+
+@st.composite
+def _get_dtype_input_and_vectors(draw):
+    dim_size = draw(helpers.ints(min_value=1, max_value=5))
+    dtype = draw(helpers.get_dtypes("float", index=1, full=False))
+    if dim_size == 1:
+        vec1 = draw(
+            helpers.array_values(
+                dtype=dtype[0], shape=(dim_size,), min_value=2, max_value=5
+            )
+        )
+        vec2 = draw(
+            helpers.array_values(
+                dtype=dtype[0], shape=(dim_size,), min_value=2, max_value=5
+            )
+        )
+    else:
+        vec1 = draw(
+            helpers.array_values(
+                dtype=dtype[0], shape=(dim_size, dim_size), min_value=2, max_value=5
+            )
+        )
+        vec2 = draw(
+            helpers.array_values(
+                dtype=dtype[0], shape=(dim_size, dim_size), min_value=2, max_value=5
+            )
+        )
+    return dtype, vec1, vec2
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_linalg/test_matrix_and_vector_products.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_linalg/test_matrix_and_vector_products.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_linalg/test_matrix_and_vector_products.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_linalg/test_matrix_and_vector_products.py
@@ -328,38 +328,9 @@ def test_numpy_multi_dot(
 
 
 # dot
-@st.composite
-def _get_dtype_input_and_vectors(draw):
-    dim_size = draw(helpers.ints(min_value=1, max_value=5))
-    dtype = draw(helpers.get_dtypes("float", index=1, full=False))
-    if dim_size == 1:
-        vec1 = draw(
-            helpers.array_values(
-                dtype=dtype[0], shape=(dim_size,), min_value=2, max_value=5
-            )
-        )
-        vec2 = draw(
-            helpers.array_values(
-                dtype=dtype[0], shape=(dim_size,), min_value=2, max_value=5
-            )
-        )
-    else:
-        vec1 = draw(
-            helpers.array_values(
-                dtype=dtype[0], shape=(dim_size, dim_size), min_value=2, max_value=5
-            )
-        )
-        vec2 = draw(
-            helpers.array_values(
-                dtype=dtype[0], shape=(dim_size, dim_size), min_value=2, max_value=5
-            )
-        )
-    return dtype, vec1, vec2
-
-
 @handle_frontend_test(
     fn_tree="numpy.dot",
-    dtype_a_b=_get_dtype_input_and_vectors(),
+    dtype_a_b=np_frontend_helpers._get_dtype_input_and_vectors(),
 )
 def test_numpy_dot(
     dtype_a_b,
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_ndarray/test_ndarray.py
@@ -932,6 +932,38 @@ def test_numpy_instance_cumsum(
     )
 
 
+@handle_frontend_method(
+    class_tree=CLASS_TREE,
+    init_tree="numpy.array",
+    method_name="dot",
+    dtype_and_x=np_frontend_helpers._get_dtype_input_and_vectors(),
+)
+def test_numpy_instance_dot(
+    dtype_and_x,
+    frontend_method_data,
+    init_flags,
+    method_flags,
+    frontend,
+    on_device,
+):
+    input_dtype, x, other = dtype_and_x
+    helpers.test_frontend_method(
+        init_input_dtypes=input_dtype,
+        init_all_as_kwargs_np={
+            "object": x,
+        },
+        method_input_dtypes=input_dtype,
+        method_all_as_kwargs_np={
+            "b": other,
+        },
+        frontend_method_data=frontend_method_data,
+        init_flags=init_flags,
+        method_flags=method_flags,
+        frontend=frontend,
+        on_device=on_device,
+    )
+
+
 @handle_frontend_method(
     class_tree=CLASS_TREE,
     init_tree="numpy.array",