Repository: ivy-llc/ivy

Issue:
corrcoef
Numpy fronted corrcoef


Discussion:

Resolving patch:
diff --git a/ivy/functional/backends/numpy/experimental/statistical.py b/ivy/functional/backends/numpy/experimental/statistical.py
--- a/ivy/functional/backends/numpy/experimental/statistical.py
+++ b/ivy/functional/backends/numpy/experimental/statistical.py
@@ -192,9 +192,12 @@ def corrcoef(
     *,
     y: Optional[np.ndarray] = None,
     rowvar: bool = True,
+    dtype: np.dtype = None,
     out: Optional[np.ndarray] = None,
 ) -> np.ndarray:
-    return np.corrcoef(x, y=y, rowvar=rowvar, dtype=x.dtype)
+    dtype = dtype if dtype is not None else np.float64
+
+    return np.corrcoef(x, y=y, rowvar=rowvar, dtype=dtype)
 
 
 @with_unsupported_dtypes(
diff --git a/ivy/functional/frontends/numpy/statistics/correlating.py b/ivy/functional/frontends/numpy/statistics/correlating.py
--- a/ivy/functional/frontends/numpy/statistics/correlating.py
+++ b/ivy/functional/frontends/numpy/statistics/correlating.py
@@ -1,6 +1,22 @@
 # global
 import ivy
-from ivy.functional.frontends.numpy.func_wrapper import to_ivy_arrays_and_back
+from ivy.functional.frontends.numpy.func_wrapper import (
+    to_ivy_arrays_and_back,
+    handle_numpy_dtype,
+)
+
+
+@handle_numpy_dtype
+@to_ivy_arrays_and_back
+def corrcoef(x, y=None, /, *, rowvar=True, bias=None, ddof=None, dtype="float64"):
+    if (bias is not None) or (ddof is not None):
+        ivy.warn("bias and ddof are deprecated and have no effect")
+
+    x = x.astype("float64")
+    if y is not None:
+        y = y.astype("float64")
+
+    return ivy.corrcoef(x, y=y, rowvar=rowvar).astype(dtype)
 
 
 @to_ivy_arrays_and_back


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_statistics/test_correlating.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_statistics/test_correlating.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_statistics/test_correlating.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_statistics/test_correlating.py
@@ -4,6 +4,50 @@
 # local
 import ivy_tests.test_ivy.helpers as helpers
 from ivy_tests.test_ivy.helpers import handle_frontend_test
+import ivy_tests.test_ivy.test_frontends.test_numpy.helpers as np_helpers
+
+
+# corrcoef
+@handle_frontend_test(
+    fn_tree="numpy.corrcoef",
+    dtype_and_x=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("float"),
+        num_arrays=2,
+        shared_dtype=True,
+        abs_smallest_val=1e-5,
+        min_num_dims=2,
+        max_num_dims=2,
+        min_dim_size=3,
+        max_dim_size=3,
+        min_value=-100,
+        max_value=100,
+    ),
+    rowvar=st.booleans(),
+    dtype=helpers.get_dtypes("float", full=False),
+)
+def test_numpy_corrcoef(
+    dtype_and_x,
+    rowvar,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+    dtype,
+    backend_fw,
+):
+    input_dtypes, x = dtype_and_x
+    np_helpers.test_frontend_function(
+        input_dtypes=input_dtypes,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        x=x[0],
+        y=x[1],
+        rowvar=rowvar,
+        dtype=dtype[0],
+        backend_to_test=backend_fw,
+    )
 
 
 # correlate