Repository: ivy-llc/ivy

Issue:
cov



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/jax/numpy/statistical.py b/ivy/functional/frontends/jax/numpy/statistical.py
--- a/ivy/functional/frontends/jax/numpy/statistical.py
+++ b/ivy/functional/frontends/jax/numpy/statistical.py
@@ -479,3 +479,10 @@ def correlate(a, v, mode="valid", precision=None):
         data_format="channel_first",
     )
     return ivy.flip(result[0, 0, out_order]) if need_flip else result[0, 0, out_order]
+
+
+@to_ivy_arrays_and_back
+def cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights=None):
+    return ivy.cov(
+        m, y, rowVar=rowvar, bias=bias, ddof=ddof, fweights=fweights, aweights=aweights
+    )


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_statistical.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_statistical.py
--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_statistical.py
+++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_jax_numpy_statistical.py
@@ -1046,3 +1046,116 @@ def test_jax_numpy_correlate(
         v=x[1],
         mode=mode,
     )
+
+
+# cov
+@st.composite
+def _get_dtype_value1_value2_cov(
+    draw,
+    available_dtypes,
+    min_num_dims=1,
+    max_num_dims=2,
+    min_dim_size=2,
+    max_dim_size=3,
+    abs_smallest_val=None,
+    min_value=None,
+    max_value=None,
+    allow_inf=False,
+    exclude_min=False,
+    exclude_max=False,
+    large_abs_safety_factor=50,
+    small_abs_safety_factor=50,
+    safety_factor_scale="log",
+):
+    shape = draw(
+        helpers.get_shape(
+            allow_none=False,
+            min_num_dims=min_num_dims,
+            max_num_dims=max_num_dims,
+            min_dim_size=min_dim_size,
+            max_dim_size=max_dim_size,
+        )
+    )
+
+    dtype = draw(st.sampled_from(available_dtypes))
+
+    values = []
+    for i in range(2):
+        values.append(
+            draw(
+                helpers.array_values(
+                    dtype=dtype,
+                    shape=shape,
+                    abs_smallest_val=abs_smallest_val,
+                    min_value=min_value,
+                    max_value=max_value,
+                    allow_inf=allow_inf,
+                    exclude_min=exclude_min,
+                    exclude_max=exclude_max,
+                    large_abs_safety_factor=large_abs_safety_factor,
+                    small_abs_safety_factor=small_abs_safety_factor,
+                    safety_factor_scale=safety_factor_scale,
+                )
+            )
+        )
+
+    value1, value2 = values[0], values[1]
+
+    # modifiers: rowVar, bias, ddof
+    rowVar = draw(st.booleans())
+    bias = draw(st.booleans())
+    ddof = draw(helpers.ints(min_value=0, max_value=1))
+
+    numVals = None
+    if rowVar is False:
+        numVals = -1 if numVals == 0 else 0
+    else:
+        numVals = 0 if len(shape) == 1 else -1
+
+    fweights = None
+
+    aweights = draw(
+        helpers.array_values(
+            dtype=dtype,
+            shape=shape[numVals],
+            abs_smallest_val=1,
+            min_value=1,
+            max_value=10,
+            allow_inf=False,
+            small_abs_safety_factor=1,
+        )
+    )
+
+    return [dtype], value1, value2, rowVar, bias, ddof, fweights, aweights
+
+
+@handle_frontend_test(
+    fn_tree="jax.numpy.cov",
+    dtypes_args=_get_dtype_value1_value2_cov(available_dtypes=["float64"]),
+    test_with_out=st.just(False),
+)
+def test_jax_numpy_cov(
+    *,
+    dtypes_args,
+    on_device,
+    fn_tree,
+    frontend,
+    test_flags,
+):
+    dtype, value1, value2, rowvar, bias, ddof, fweights, aweights = dtypes_args
+    helpers.test_frontend_function(
+        input_dtypes=dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        rtol=1e-3,
+        atol=1e-3,
+        on_device=on_device,
+        m=value1,
+        y=value2,
+        rowvar=rowvar,
+        bias=bias,
+        ddof=ddof,
+        fweights=fweights,
+        aweights=aweights,
+    )