Repository: ivy-llc/ivy

Issue:
fmax



Discussion:
This issue has been labelled as stale. If you would like to continue working on this issue, then please add another comment or create a PR . If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. For more information please refer to this page in our documentation: https://lets-unify.ai/ivy/contributing/1_the_basics.html#todo-list-issues
I was waiting until the task gets assigned to me, I'm working on it as of now

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/__init__.py b/ivy/functional/frontends/numpy/__init__.py
--- a/ivy/functional/frontends/numpy/__init__.py
+++ b/ivy/functional/frontends/numpy/__init__.py
@@ -601,6 +601,7 @@ def promote_types_of_numpy_inputs(
 from ivy.functional.frontends.numpy.mathematical_functions.extrema_finding import (
     _maximum,
     _minimum,
+    _fmax,
 )
 
 # initializing ufuncs #
@@ -671,3 +672,4 @@ def promote_types_of_numpy_inputs(
 minimum = ufunc("_minimum")
 real = ufunc("_real")
 divmod = ufunc("_divmod")
+fmax = ufunc("_fmax")
diff --git a/ivy/functional/frontends/numpy/mathematical_functions/extrema_finding.py b/ivy/functional/frontends/numpy/mathematical_functions/extrema_finding.py
--- a/ivy/functional/frontends/numpy/mathematical_functions/extrema_finding.py
+++ b/ivy/functional/frontends/numpy/mathematical_functions/extrema_finding.py
@@ -239,3 +239,25 @@ def nanmax(
     if where_mask is not None and ivy.any(where_mask):
         res = ivy.where(ivy.logical_not(where_mask), res, ivy.nan, out=out)
     return ivy.astype(res, out_dtype, out=out, copy=False)
+
+
+@handle_numpy_out
+@to_ivy_arrays_and_back
+@from_zero_dim_arrays_to_scalar
+def _fmax(
+    x1,
+    x2,
+    /,
+    out=None,
+    *,
+    where=True,
+    casting="same_kind",
+    order="K",
+    dtype=None,
+    subok=True,
+):
+    ret = ivy.fmax(x1, x2, out=out)
+    if ivy.is_array(where):
+        ret = ivy.where(where, ret, ivy.default(out, ivy.zeros_like(ret)), out=out)
+    return ret
+


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_mathematical_functions/test_extrema_finding.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_mathematical_functions/test_extrema_finding.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_mathematical_functions/test_extrema_finding.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_mathematical_functions/test_extrema_finding.py
@@ -302,3 +302,45 @@ def test_numpy_nanmax(
         initial=initial,
         where=where,
     )
+
+
+# fmax
+@handle_frontend_test(
+    fn_tree="numpy.fmax",
+    dtype_and_inputs=helpers.dtype_and_values(
+        available_dtypes=helpers.get_dtypes("float"),
+        num_arrays=2,
+        min_value=-np.inf,
+        max_value=np.inf,
+        shared_dtype=True,
+    ),
+    where=np_frontend_helpers.where(),
+    number_positional_args=np_frontend_helpers.get_num_positional_args_ufunc(
+        fn_name="fmax"
+    ),
+)
+def test_numpy_fmax(
+    dtype_and_inputs,
+    where,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+):
+    input_dtypes, xs = dtype_and_inputs
+    where, input_dtypes, test_flags = np_frontend_helpers.handle_where_and_array_bools(
+        where=where,
+        input_dtype=input_dtypes,
+        test_flags=test_flags,
+    )
+    np_frontend_helpers.test_frontend_function(
+        input_dtypes=input_dtypes,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        x1=xs[0],
+        x2=xs[1],
+        out=None,
+        where=where,
+    )