Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utility functions for tests #29

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tests/utility_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pytest

import arrayfire_wrapper.lib as wrapper
from arrayfire_wrapper.dtypes import Dtype, c32, c64, f16, f32, f64, s16, s32, s64, u8, u16, u32, u64


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 double types")

if dtype == f16 and not wrapper.get_half_support():
pytest.skip("Device does not support half types.")


def get_complex_types() -> list:
"""Returns all complex types"""
return [c32, c64]


def get_real_types() -> list:
"""Returns all real types"""
return [s16, s32, s64, u8, u16, u32, u64, f16, f32, f64]


def get_all_types() -> list:
"""Returns all types"""
return [s16, s32, s64, u8, u16, u32, u64, f16, f32, f64, c32, c64]
Loading