From e4f27553777b2edf945cda4cfa18cab22149dca8 Mon Sep 17 00:00:00 2001 From: Chaluvadi Date: Wed, 13 Mar 2024 09:37:30 -0400 Subject: [PATCH 1/5] Added utility functions for tests --- tests/test_utilities.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/test_utilities.py diff --git a/tests/test_utilities.py b/tests/test_utilities.py new file mode 100644 index 0000000..90ff154 --- /dev/null +++ b/tests/test_utilities.py @@ -0,0 +1,16 @@ +import pytest + +import arrayfire_wrapper.lib as wrapper + +from arrayfire_wrapper.dtypes import f64, c32, c64, Dtype + +def is_cmplx_type(dtype: Dtype) -> bool: + """Checks to see if the specified type is a complex type""" + return dtype == c32 or dtype == c64 + +def is_system_supported(dtype: Dtype) -> bool: + """Checks to see if the specified type is supported by the current system""" + if dtype in [f64, c64] and not wrapper.get_dbl_support(): + return False + + return True \ No newline at end of file From 77931b91c879e3c257299a89e939f7b21091c9e4 Mon Sep 17 00:00:00 2001 From: Chaluvadi Date: Wed, 13 Mar 2024 09:42:25 -0400 Subject: [PATCH 2/5] Fixed utility functions for tests --- tests/test_utilities.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_utilities.py b/tests/test_utilities.py index 90ff154..a29f747 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -1,16 +1,15 @@ -import pytest - import arrayfire_wrapper.lib as wrapper from arrayfire_wrapper.dtypes import f64, c32, c64, Dtype + def is_cmplx_type(dtype: Dtype) -> bool: """Checks to see if the specified type is a complex type""" return dtype == c32 or dtype == c64 + def is_system_supported(dtype: Dtype) -> bool: """Checks to see if the specified type is supported by the current system""" if dtype in [f64, c64] and not wrapper.get_dbl_support(): return False - - return True \ No newline at end of file + return True From 4dbbe3124916236e81dda4762cebde4cdb93fadc Mon Sep 17 00:00:00 2001 From: Chaluvadi Date: Wed, 13 Mar 2024 09:58:23 -0400 Subject: [PATCH 3/5] Fixed utility functions for tests pt. 2 --- tests/test_utilities.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_utilities.py b/tests/test_utilities.py index a29f747..59053b8 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -1,6 +1,7 @@ import arrayfire_wrapper.lib as wrapper +import pytest -from arrayfire_wrapper.dtypes import f64, c32, c64, Dtype +from arrayfire_wrapper.dtypes import f64, f16, c32, c64, Dtype def is_cmplx_type(dtype: Dtype) -> bool: @@ -8,8 +9,11 @@ def is_cmplx_type(dtype: Dtype) -> bool: return dtype == c32 or dtype == c64 -def is_system_supported(dtype: Dtype) -> bool: +def check_type_supported(dtype: Dtype) -> None: """Checks to see if the specified type is supported by the current system""" if dtype in [f64, c64] and not wrapper.get_dbl_support(): - return False - return True + pytest.skip("Device does not support doubel types.") + + if dtype == f16 and not wrapper.get_half_support(): + pytest.skip("Device does not support half types.") + From 8bc8102e628bf6ec270582ef9d108e43dfb7554f Mon Sep 17 00:00:00 2001 From: Chaluvadi Date: Wed, 13 Mar 2024 09:59:40 -0400 Subject: [PATCH 4/5] Fixed constants --- tests/test_constants.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_constants.py b/tests/test_constants.py index 855d94a..1835a9c 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -174,7 +174,7 @@ def test_constant_dtype(dtype_index: int) -> None: ) def test_constant_complex_dtype(dtype_index: int) -> None: """Test if constant_complex creates an array with the correct dtype.""" - if dtype_index not in [1, 3] or (dtype_index == 3 and not wrapper.get_dbl_support()): + if not pytest.skip() dtype = dtypes.c_api_value_to_dtype(dtype_index) @@ -219,3 +219,4 @@ def test_constant_ulong_dtype() -> None: assert dtypes.c_api_value_to_dtype(wrapper.get_type(result)) == dtype else: pytest.skip() + \ No newline at end of file From 5ce3c14ac7fca93e9003dde7c3f1f89b0e9a80b4 Mon Sep 17 00:00:00 2001 From: Chaluvadi Date: Wed, 13 Mar 2024 10:26:04 -0400 Subject: [PATCH 5/5] Fixed utility functions --- tests/test_utilities.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/test_utilities.py b/tests/test_utilities.py index 59053b8..3e45f78 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -1,19 +1,13 @@ -import arrayfire_wrapper.lib as wrapper import pytest -from arrayfire_wrapper.dtypes import f64, f16, c32, c64, Dtype - - -def is_cmplx_type(dtype: Dtype) -> bool: - """Checks to see if the specified type is a complex type""" - return dtype == c32 or dtype == c64 +import arrayfire_wrapper.lib as wrapper +from arrayfire_wrapper.dtypes import Dtype, c64, f16, f64 def check_type_supported(dtype: Dtype) -> None: """Checks to see if the specified type is supported by the current system""" if dtype in [f64, c64] and not wrapper.get_dbl_support(): - pytest.skip("Device does not support doubel types.") + pytest.skip("Device does not support double types") if dtype == f16 and not wrapper.get_half_support(): pytest.skip("Device does not support half types.") -