Refines NDArray indexing and adds numpy ndarray indexing [READY FOR REVIEW]#15942
Refines NDArray indexing and adds numpy ndarray indexing [READY FOR REVIEW]#15942reminisce merged 3 commits intoapache:masterfrom
Conversation
| """ | ||
| return self.copyto(self.context) | ||
|
|
||
| def slice_assign_scalar(self, value, begin, end, step): |
There was a problem hiding this comment.
Why a wrapper on top of _internal._slice_assign_scalar is needed?
There was a problem hiding this comment.
To enable polymorphism and reuse code as much as possible. I reused NDArray's _set_nd_basic_indexing function in ndarray class and wrapping slice_assign_scalar and slice_assign as class methods can let python automatically call NDArray operators in NDArray processing, and ndarray ones in ndarray processing. If you feel such handling confusing, I can also copy-paste the entire _set_nd_basic_indexing function to multiarray.py.
There was a problem hiding this comment.
Same for some other operators like _full and scatter_set_nd.
| """ | ||
| return _internal._slice_assign_scalar(self, value, begin=begin, end=end, step=step, out=self) | ||
|
|
||
| def slice_assign(self, rhs, begin, end, step): |
| """ | ||
| return to_dlpack_for_write(self) | ||
|
|
||
| def _full(self, value): |
| """ | ||
| return _internal._full(self.shape, value=value, ctx=self.context, dtype=self.dtype, out=self) | ||
|
|
||
| def _scatter_set_nd(self, value_nd, indices): |
1973c3a to
e50c351
Compare
7f71f00 to
e17a563
Compare
|
Waiting for CI result. Still fixing style. |
2ab9211 to
40459bd
Compare
|
Fixed SliceAxisGrad_ and now supports subscription on zero-size shapes (eg. x = np.ones((3, 0))) |
5f29819 to
9ff4d57
Compare
9ff4d57 to
2052fb7
Compare
Description
https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments