Skip to content

[Data API] Array Object Implementation #261

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

Merged
merged 29 commits into from
Apr 25, 2023
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
75c1d43
Refactoring of basic functionality to create an empty Array
Jan 24, 2023
b14aa91
Replace dim4 with CShape
roaffix Jan 24, 2023
eadbe9b
Add tests. Minor fixes. Update CI
roaffix Jan 24, 2023
c13a59f
Fix CI
roaffix Jan 24, 2023
f0f57e8
Add arithmetic operators w/o tests
roaffix Jan 26, 2023
8cef774
Fix array init bug. Add __getitem__. Change pytest for active debug mode
roaffix Jan 27, 2023
a4c7ac9
Add reflected arithmetic and array operators
roaffix Jan 27, 2023
4140527
Place TODO for repr
roaffix Jan 28, 2023
4374d93
Add bitwise operators. Add in-place operators. Add missing reflected …
roaffix Jan 28, 2023
5a29ffa
Fix tests
roaffix Jan 28, 2023
4187b27
Add tests for arithmetic operators
roaffix Jan 28, 2023
cdb7a92
Added to_list and to_ctypes_array
roaffix Jan 28, 2023
9c0435a
Fix bug when scalar is empty returns None
roaffix Jan 28, 2023
769c16c
Fix typing in array object. Add tests
roaffix Jan 29, 2023
fb27e46
Change tests and found bug with reflected operators
roaffix Jan 29, 2023
0afb92e
Fix reflected operators bug. Add test coverage for the rest of the ar…
roaffix Jan 29, 2023
1d071be
Add required by specification methods
roaffix Jan 30, 2023
04fbb1b
Change file names
roaffix Jan 30, 2023
2d91b04
Change utils. Add docstrings
roaffix Jan 30, 2023
5939388
Add docstrings for operators
roaffix Jan 30, 2023
0231e27
Change TODOs
roaffix Jan 30, 2023
07c4206
Add docstrings for other operators. Remove docstrings from mocks
roaffix Jan 30, 2023
908447b
Change tags and typings
roaffix Feb 4, 2023
fa3ad06
Change typings from python 3.10 to python 3.8
roaffix Feb 4, 2023
0de9955
Add readme with reference to run tests
roaffix Feb 4, 2023
ae6be05
Revert changes accidentally made in original array
roaffix Feb 5, 2023
15bc8cb
Add constructor initialisation warning. Add Note on deviation from sp…
roaffix Apr 25, 2023
e24e478
Fix warning message
roaffix Apr 25, 2023
f3a80c0
Add NOTE tag to functions that are not a part of spec but custom solu…
roaffix Apr 25, 2023
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
Prev Previous commit
Next Next commit
Add reflected arithmetic and array operators
  • Loading branch information
roaffix committed Jan 27, 2023
commit a4c7ac9cf45d5b8a92f3c02fcad81cfb2034df4e
45 changes: 45 additions & 0 deletions arrayfire/array_api/_array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,51 @@ def __matmul__(self, other: Array, /) -> Array:
# TODO
return NotImplemented

def __radd__(self, other: Array, /) -> Array:
# TODO discuss either we need to support complex and bool as other input type
"""
Return other + self.
"""
return _process_c_function(other, self, backend.get().af_add)

def __rsub__(self, other: Array, /) -> Array:
"""
Return other - self.
"""
return _process_c_function(other, self, backend.get().af_sub)

def __rmul__(self, other: Array, /) -> Array:
"""
Return other * self.
"""
return _process_c_function(other, self, backend.get().af_mul)

def __rtruediv__(self, other: Array, /) -> Array:
"""
Return other / self.
"""
return _process_c_function(other, self, backend.get().af_div)

def __rfloordiv__(self, other: Array, /) -> Array:
# TODO
return NotImplemented

def __rmod__(self, other: Array, /) -> Array:
"""
Return other / self.
"""
return _process_c_function(other, self, backend.get().af_mod)

def __rpow__(self, other: Array, /) -> Array:
"""
Return other ** self.
"""
return _process_c_function(other, self, backend.get().af_pow)

def __rmatmul__(self, other: Array, /) -> Array:
# TODO
return NotImplemented

def __getitem__(self, key: int | slice | tuple[int | slice] | Array, /) -> Array:
# TODO: API Specification - key: int | slice | ellipsis | tuple[int | slice] | Array
# TODO: refactor
Expand Down