diff --git a/arrayfire_wrapper/_backend.py b/arrayfire_wrapper/_backend.py index 2644831..585a92c 100644 --- a/arrayfire_wrapper/_backend.py +++ b/arrayfire_wrapper/_backend.py @@ -1,4 +1,4 @@ -__all__ = ["BackendType"] +__all__ = ["BackendType", "get_backend", "set_backend"] import ctypes import enum diff --git a/arrayfire_wrapper/lib/create_and_modify_array/create_array/pad.py b/arrayfire_wrapper/lib/create_and_modify_array/create_array/pad.py index 7fd8b21..cd9772c 100644 --- a/arrayfire_wrapper/lib/create_and_modify_array/create_array/pad.py +++ b/arrayfire_wrapper/lib/create_and_modify_array/create_array/pad.py @@ -17,9 +17,9 @@ def pad(arr: AFArray, begin_shape: tuple[int, ...], end_shape: tuple[int, ...], ctypes.pointer(out), arr, 4, - begin_c_shape.c_array, + ctypes.pointer(begin_c_shape.c_array), 4, - end_c_shape.c_array, + ctypes.pointer(end_c_shape.c_array), border_type.value, ) return out diff --git a/arrayfire_wrapper/lib/create_and_modify_array/manage_device.py b/arrayfire_wrapper/lib/create_and_modify_array/manage_device.py index 12673f9..49a7614 100644 --- a/arrayfire_wrapper/lib/create_and_modify_array/manage_device.py +++ b/arrayfire_wrapper/lib/create_and_modify_array/manage_device.py @@ -11,6 +11,8 @@ def alloc_host(num_bytes: int, /) -> int: Allocate a buffer on the host with specified number of bytes. """ + # TODO + # Avoid using AFArray and use ctypes.c_void_p to avoid misunderstanding 'coz its not actually an array out = AFArray.create_null_pointer() call_from_clib(alloc_host.__name__, ctypes.pointer(out), CDimT(num_bytes)) return out.value # type: ignore[return-value] diff --git a/arrayfire_wrapper/lib/create_and_modify_array/move_and_reorder.py b/arrayfire_wrapper/lib/create_and_modify_array/move_and_reorder.py index c1e17e1..240412d 100644 --- a/arrayfire_wrapper/lib/create_and_modify_array/move_and_reorder.py +++ b/arrayfire_wrapper/lib/create_and_modify_array/move_and_reorder.py @@ -78,25 +78,31 @@ def replace_scalar(lhs: AFArray, cond_arr: AFArray, rhs: int | float, /) -> None call_from_clib(replace.__name__, lhs, cond_arr, ctypes.c_double(rhs)) -def select(lhs: AFArray, cond_arr: AFArray, rhs: AFArray, /) -> None: +def select(lhs: AFArray, cond_arr: AFArray, rhs: AFArray, /) -> AFArray: """ source: https://arrayfire.org/docs/group__data__func__select.htm#gac4af16e31ddd5ddcf09b670f676fd093 """ - call_from_clib(select.__name__, cond_arr, lhs, rhs) + out = AFArray.create_null_pointer() + call_from_clib(select.__name__, ctypes.pointer(out), cond_arr, lhs, rhs) + return out -def select_scalar_l(lhs: int | float, cond_arr: AFArray, rhs: AFArray, /) -> None: +def select_scalar_l(lhs: int | float, cond_arr: AFArray, rhs: AFArray, /) -> AFArray: """ source: https://arrayfire.org/docs/group__data__func__select.htm#gac4af16e31ddd5ddcf09b670f676fd093 """ - call_from_clib(select_scalar_l.__name__, cond_arr, ctypes.c_double(lhs), rhs) + out = AFArray.create_null_pointer() + call_from_clib(select_scalar_l.__name__, ctypes.pointer(out), cond_arr, ctypes.c_double(lhs), rhs) + return out -def select_scalar_r(lhs: AFArray, cond_arr: AFArray, rhs: int | float, /) -> None: +def select_scalar_r(lhs: AFArray, cond_arr: AFArray, rhs: int | float, /) -> AFArray: """ source: https://arrayfire.org/docs/group__data__func__select.htm#gac4af16e31ddd5ddcf09b670f676fd093 """ - call_from_clib(select_scalar_l.__name__, cond_arr, lhs, ctypes.c_double(rhs)) + out = AFArray.create_null_pointer() + call_from_clib(select_scalar_l.__name__, ctypes.pointer(out), cond_arr, lhs, ctypes.c_double(rhs)) + return out def shift(arr: AFArray, /, d0: int, d1: int = 0, d2: int = 0, d3: int = 0) -> AFArray: diff --git a/arrayfire_wrapper/lib/vector_algorithms/reduction_operations.py b/arrayfire_wrapper/lib/vector_algorithms/reduction_operations.py index 48af56e..3f25e96 100644 --- a/arrayfire_wrapper/lib/vector_algorithms/reduction_operations.py +++ b/arrayfire_wrapper/lib/vector_algorithms/reduction_operations.py @@ -144,9 +144,7 @@ def max_ragged(arr: AFArray, ragged_len: AFArray, dim: int, /) -> tuple[AFArray, """ out_values = AFArray.create_null_pointer() out_idx = AFArray.create_null_pointer() - call_from_clib( - max_ragged.__name__, ctypes.pointer(out_values), ctypes.pointer(out_idx), arr, ragged_len, ctypes.c_int(dim) - ) + call_from_clib(max_ragged.__name__, ctypes.pointer(out_values), ctypes.pointer(out_idx), arr, ragged_len, dim) return (out_values, out_idx) @@ -156,9 +154,7 @@ def max_by_key(keys: AFArray, values: AFArray, dim: int, /) -> tuple[AFArray, AF """ out_keys = AFArray.create_null_pointer() out_values = AFArray.create_null_pointer() - call_from_clib( - max_by_key.__name__, ctypes.pointer(out_keys), ctypes.pointer(out_values), keys, values, ctypes.c_int(dim) - ) + call_from_clib(max_by_key.__name__, ctypes.pointer(out_keys), ctypes.pointer(out_values), keys, values, dim) return (out_keys, out_values) diff --git a/arrayfire_wrapper/lib/vector_algorithms/set_operations.py b/arrayfire_wrapper/lib/vector_algorithms/set_operations.py index 43853e3..09a9f61 100644 --- a/arrayfire_wrapper/lib/vector_algorithms/set_operations.py +++ b/arrayfire_wrapper/lib/vector_algorithms/set_operations.py @@ -27,5 +27,5 @@ def set_unique(arr: AFArray, is_sorted: bool, /) -> AFArray: source: https://arrayfire.org/docs/group__set__func__unique.htm#ga6afa1de48cbbc4b2df530c2530087943 """ out = AFArray.create_null_pointer() - call_from_clib(set_intersect.__name__, ctypes.pointer(out), ctypes.c_bool(is_sorted)) + call_from_clib(set_unique.__name__, ctypes.pointer(out), arr, ctypes.c_bool(is_sorted)) return out diff --git a/arrayfire_wrapper/version.py b/arrayfire_wrapper/version.py index 79ca4ff..5b08d8d 100644 --- a/arrayfire_wrapper/version.py +++ b/arrayfire_wrapper/version.py @@ -1,7 +1,7 @@ import os _MAJOR = "0" -_MINOR = "6" +_MINOR = "7" # On main and in a nightly release the patch should be one ahead of the last # released build. _PATCH = "0" diff --git a/pyproject.toml b/pyproject.toml index 76c3830..d975945 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ build-backend = "scikit_build_core.build" [project] name = "arrayfire-binary-python-wrapper" -version = "0.6.0+AF3.9.0" +version = "0.7.0+AF3.9.0" requires-python = ">=3.10" authors = [ { name = "ArrayFire", email = "technical@arrayfire.com"},