Skip to content

Commit 0231e27

Browse files
committed
Change TODOs
1 parent 5939388 commit 0231e27

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ jobs:
2222
- name: Test with pytest
2323
run: pytest
2424

25+
- name: Install AF
26+
run: apt install arrayfire
27+
2528
- name: Test array_api
2629
run: python -m pytest arrayfire/array_api

arrayfire/array_api/array_object.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
from .dtypes import uint64 as af_uint64
2424

2525
ShapeType = tuple[int, ...]
26-
_bcast_var = False # HACK, TODO replace for actual bcast_var after refactoring
26+
# HACK, TODO replace for actual bcast_var after refactoring ~ https://github.com/arrayfire/arrayfire/pull/2871
27+
_bcast_var = False
28+
29+
# TODO use int | float in operators -> remove bool | complex support
2730

2831

2932
@dataclass
@@ -33,12 +36,6 @@ class _ArrayBuffer:
3336

3437

3538
class Array:
36-
# Numpy checks this attribute to know which class handles binary builtin operations, such as __add__.
37-
# Setting to such a high value should make sure that arrayfire has priority over
38-
# other classes, ensuring that e.g. numpy.float32(1)*arrayfire.randu(3) is handled by
39-
# arrayfire's __radd__() instead of numpy's __add__()
40-
__array_priority__ = 30 # TODO discuss its purpose
41-
4239
def __init__(
4340
self, x: None | Array | py_array.array | int | ctypes.c_void_p | list = None,
4441
dtype: None | Dtype | str = None, shape: None | ShapeType = None,
@@ -164,7 +161,6 @@ def __neg__(self) -> Array:
164161
return 0 - self # type: ignore[no-any-return, operator] # FIXME
165162

166163
def __add__(self, other: int | float | Array, /) -> Array:
167-
# TODO discuss either we need to support complex and bool as other input type
168164
"""
169165
Calculates the sum for each element of an array instance with the respective element of the array other.
170166
@@ -300,21 +296,13 @@ def __pow__(self, other: int | float | Array, /) -> Array:
300296
out : Array
301297
An array containing the element-wise results. The returned array must have a data type determined
302298
by Type Promotion Rules.
303-
304-
Note
305-
----
306-
- If both self and other have integer data types, the result of __pow__ when other_i is negative
307-
(i.e., less than zero) is unspecified and thus implementation-dependent.
308-
If self has an integer data type and other has a floating-point data type, behavior is
309-
implementation-dependent, as type promotion between data type “kinds” (e.g., integer versus floating-point)
310-
is unspecified.
311299
"""
312300
return _process_c_function(self, other, backend.get().af_pow)
313301

314302
# Array Operators
315303

316304
def __matmul__(self, other: Array, /) -> Array:
317-
# TODO
305+
# TODO get from blas - make vanilla version and not copy af.matmul as is
318306
return NotImplemented
319307

320308
# Bitwise Operators
@@ -508,7 +496,7 @@ def __rfloordiv__(self, other: Array, /) -> Array:
508496

509497
def __rmod__(self, other: Array, /) -> Array:
510498
"""
511-
Return other / self.
499+
Return other % self.
512500
"""
513501
return _process_c_function(other, self, backend.get().af_mod)
514502

@@ -534,7 +522,7 @@ def __rand__(self, other: Array, /) -> Array:
534522

535523
def __ror__(self, other: Array, /) -> Array:
536524
"""
537-
Return other & self.
525+
Return other | self.
538526
"""
539527
return _process_c_function(other, self, backend.get().af_bitor)
540528

@@ -648,7 +636,7 @@ def __array_namespace__(self, *, api_version: None | str = None) -> Any:
648636
return NotImplemented
649637

650638
def __bool__(self) -> bool:
651-
# TODO
639+
# TODO consider using scalar() and is_scalar()
652640
return NotImplemented
653641

654642
def __complex__(self) -> complex:
@@ -668,7 +656,7 @@ def __float__(self) -> float:
668656
return NotImplemented
669657

670658
def __getitem__(self, key: int | slice | tuple[int | slice] | Array, /) -> Array:
671-
# TODO: API Specification - key: int | slice | ellipsis | tuple[int | slice] | Array
659+
# TODO: API Specification - key: int | slice | ellipsis | tuple[int | slice] | Array - consider using af.span
672660
# TODO: refactor
673661
out = Array()
674662
ndims = self.ndim

arrayfire/array_api/tests/test_array_object.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# TODO change separated methods with setup and teardown to avoid code duplication
1010
# TODO add tests for array arguments: device, offset, strides
1111
# TODO add tests for all supported dtypes on initialisation
12+
# TODO check if e.g. abs(x1-x2) < 1e-6 ~ https://davidamos.dev/the-right-way-to-compare-floats-in-python/
1213

1314

1415
def test_create_empty_array() -> None:

0 commit comments

Comments
 (0)