From 313a167a237a9d5f17161e91da0083a75cfcee84 Mon Sep 17 00:00:00 2001 From: Shireen Chand <72601697+shireenchand@users.noreply.github.com> Date: Sun, 19 Feb 2023 01:38:03 +0530 Subject: [PATCH] isfortran (#10565) Co-authored-by: Vansh Gupta --- .../numpy/logic/truth_value_testing.py | 6 +++++ .../test_logic/test_truth_value_testing.py | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/ivy/functional/frontends/numpy/logic/truth_value_testing.py b/ivy/functional/frontends/numpy/logic/truth_value_testing.py index a9457de348f41..b577bda0b8f99 100644 --- a/ivy/functional/frontends/numpy/logic/truth_value_testing.py +++ b/ivy/functional/frontends/numpy/logic/truth_value_testing.py @@ -1,5 +1,6 @@ # global import ivy +import numpy as np from ivy.functional.frontends.numpy.func_wrapper import ( to_ivy_arrays_and_back, from_zero_dim_arrays_to_scalar, @@ -50,3 +51,8 @@ def isscalar(element): or isinstance(element, bool) or isinstance(element, float) ) + + +@to_ivy_arrays_and_back +def isfortran(a: np.ndarray): + return a.flags.fnc diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_logic/test_truth_value_testing.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_logic/test_truth_value_testing.py index 5b429a64e8f18..396359f6ddc59 100644 --- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_logic/test_truth_value_testing.py +++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_logic/test_truth_value_testing.py @@ -115,3 +115,29 @@ def test_numpy_isscalar( on_device=on_device, element=element, ) + + +@handle_frontend_test( + fn_tree="numpy.isfortran", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("float"), min_num_dims=1 + ), + test_with_out=st.just(False), +) +def test_numpy_isfortran( + dtype_and_x, + frontend, + on_device, + *, + fn_tree, + test_flags, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_function( + input_dtypes=input_dtype, + frontend=frontend, + test_flags=test_flags, + fn_tree=fn_tree, + on_device=on_device, + a=x[0], + )