Skip to content

Commit

Permalink
added ptp method to jax frontend array (#21117)
Browse files Browse the repository at this point in the history
Co-authored-by: juliagsy <67888047+juliagsy@users.noreply.github.com>
  • Loading branch information
arham-kk and juliagsy authored Aug 7, 2023
1 parent e27bc78 commit 602e7e2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ivy/functional/frontends/jax/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,12 @@ def var(
keepdims=keepdims,
where=where,
)

def ptp(
self,
*,
axis=None,
out=None,
keepdims=False,
):
return jax_frontend.numpy.ptp(self, axis=axis, out=out, keepdims=keepdims)
43 changes: 43 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_jax/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -2231,3 +2231,46 @@ def test_jax_array_min(
method_flags=method_flags,
on_device=on_device,
)


# ptp
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="jax.numpy.array",
method_name="ptp",
dtype_and_x=helpers.dtype_values_axis(
available_dtypes=helpers.get_dtypes("float"),
force_int_axis=True,
min_num_dims=1,
valid_axis=True,
),
keepdims=st.booleans(),
)
def test_jax_array_ptp(
dtype_and_x,
keepdims,
on_device,
frontend,
backend_fw,
frontend_method_data,
init_flags,
method_flags,
):
input_dtype, x, axis = dtype_and_x
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
backend_to_test=backend_fw,
init_all_as_kwargs_np={
"object": x[0],
},
method_input_dtypes=input_dtype,
method_all_as_kwargs_np={
"axis": axis,
"keepdims": keepdims,
},
frontend=frontend,
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
on_device=on_device,
)

0 comments on commit 602e7e2

Please sign in to comment.