Skip to content

Commit da6edbb

Browse files
committed
Bug fixes. Minor build changes
1 parent 5850b9a commit da6edbb

File tree

8 files changed

+22
-18
lines changed

8 files changed

+22
-18
lines changed

arrayfire_wrapper/_backend.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__all__ = ["BackendType"]
1+
__all__ = ["BackendType", "get_backend", "set_backend"]
22

33
import ctypes
44
import enum

arrayfire_wrapper/lib/create_and_modify_array/create_array/pad.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def pad(arr: AFArray, begin_shape: tuple[int, ...], end_shape: tuple[int, ...],
1717
ctypes.pointer(out),
1818
arr,
1919
4,
20-
begin_c_shape.c_array,
20+
ctypes.pointer(begin_c_shape.c_array),
2121
4,
22-
end_c_shape.c_array,
22+
ctypes.pointer(end_c_shape.c_array),
2323
border_type.value,
2424
)
2525
return out

arrayfire_wrapper/lib/create_and_modify_array/manage_device.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ def alloc_host(num_bytes: int, /) -> int:
1111
1212
Allocate a buffer on the host with specified number of bytes.
1313
"""
14+
# TODO
15+
# Avoid using AFArray and use ctypes.c_void_p to avoid misunderstanding 'coz its not actually an array
1416
out = AFArray.create_null_pointer()
1517
call_from_clib(alloc_host.__name__, ctypes.pointer(out), CDimT(num_bytes))
1618
return out.value # type: ignore[return-value]

arrayfire_wrapper/lib/create_and_modify_array/move_and_reorder.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,31 @@ def replace_scalar(lhs: AFArray, cond_arr: AFArray, rhs: int | float, /) -> None
7878
call_from_clib(replace.__name__, lhs, cond_arr, ctypes.c_double(rhs))
7979

8080

81-
def select(lhs: AFArray, cond_arr: AFArray, rhs: AFArray, /) -> None:
81+
def select(lhs: AFArray, cond_arr: AFArray, rhs: AFArray, /) -> AFArray:
8282
"""
8383
source: https://arrayfire.org/docs/group__data__func__select.htm#gac4af16e31ddd5ddcf09b670f676fd093
8484
"""
85-
call_from_clib(select.__name__, cond_arr, lhs, rhs)
85+
out = AFArray.create_null_pointer()
86+
call_from_clib(select.__name__, ctypes.pointer(out), cond_arr, lhs, rhs)
87+
return out
8688

8789

88-
def select_scalar_l(lhs: int | float, cond_arr: AFArray, rhs: AFArray, /) -> None:
90+
def select_scalar_l(lhs: int | float, cond_arr: AFArray, rhs: AFArray, /) -> AFArray:
8991
"""
9092
source: https://arrayfire.org/docs/group__data__func__select.htm#gac4af16e31ddd5ddcf09b670f676fd093
9193
"""
92-
call_from_clib(select_scalar_l.__name__, cond_arr, ctypes.c_double(lhs), rhs)
94+
out = AFArray.create_null_pointer()
95+
call_from_clib(select_scalar_l.__name__, ctypes.pointer(out), cond_arr, ctypes.c_double(lhs), rhs)
96+
return out
9397

9498

95-
def select_scalar_r(lhs: AFArray, cond_arr: AFArray, rhs: int | float, /) -> None:
99+
def select_scalar_r(lhs: AFArray, cond_arr: AFArray, rhs: int | float, /) -> AFArray:
96100
"""
97101
source: https://arrayfire.org/docs/group__data__func__select.htm#gac4af16e31ddd5ddcf09b670f676fd093
98102
"""
99-
call_from_clib(select_scalar_l.__name__, cond_arr, lhs, ctypes.c_double(rhs))
103+
out = AFArray.create_null_pointer()
104+
call_from_clib(select_scalar_l.__name__, ctypes.pointer(out), cond_arr, lhs, ctypes.c_double(rhs))
105+
return out
100106

101107

102108
def shift(arr: AFArray, /, d0: int, d1: int = 0, d2: int = 0, d3: int = 0) -> AFArray:

arrayfire_wrapper/lib/vector_algorithms/reduction_operations.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ def max_ragged(arr: AFArray, ragged_len: AFArray, dim: int, /) -> tuple[AFArray,
144144
"""
145145
out_values = AFArray.create_null_pointer()
146146
out_idx = AFArray.create_null_pointer()
147-
call_from_clib(
148-
max_ragged.__name__, ctypes.pointer(out_values), ctypes.pointer(out_idx), arr, ragged_len, ctypes.c_int(dim)
149-
)
147+
call_from_clib(max_ragged.__name__, ctypes.pointer(out_values), ctypes.pointer(out_idx), arr, ragged_len, dim)
150148
return (out_values, out_idx)
151149

152150

@@ -156,9 +154,7 @@ def max_by_key(keys: AFArray, values: AFArray, dim: int, /) -> tuple[AFArray, AF
156154
"""
157155
out_keys = AFArray.create_null_pointer()
158156
out_values = AFArray.create_null_pointer()
159-
call_from_clib(
160-
max_by_key.__name__, ctypes.pointer(out_keys), ctypes.pointer(out_values), keys, values, ctypes.c_int(dim)
161-
)
157+
call_from_clib(max_by_key.__name__, ctypes.pointer(out_keys), ctypes.pointer(out_values), keys, values, dim)
162158
return (out_keys, out_values)
163159

164160

arrayfire_wrapper/lib/vector_algorithms/set_operations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ def set_unique(arr: AFArray, is_sorted: bool, /) -> AFArray:
2727
source: https://arrayfire.org/docs/group__set__func__unique.htm#ga6afa1de48cbbc4b2df530c2530087943
2828
"""
2929
out = AFArray.create_null_pointer()
30-
call_from_clib(set_intersect.__name__, ctypes.pointer(out), ctypes.c_bool(is_sorted))
30+
call_from_clib(set_unique.__name__, ctypes.pointer(out), arr, ctypes.c_bool(is_sorted))
3131
return out

arrayfire_wrapper/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22

33
_MAJOR = "0"
4-
_MINOR = "6"
4+
_MINOR = "7"
55
# On main and in a nightly release the patch should be one ahead of the last
66
# released build.
77
_PATCH = "0"

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ build-backend = "scikit_build_core.build"
2929

3030
[project]
3131
name = "arrayfire-binary-python-wrapper"
32-
version = "0.6.0+AF3.9.0"
32+
version = "0.7.0+AF3.9.0"
3333
requires-python = ">=3.10"
3434
authors = [
3535
{ name = "ArrayFire", email = "[email protected]"},

0 commit comments

Comments
 (0)