Use the Variant[Slice, Int] as the uniformed way to __getitem__. The __getitem__ always returns an array.
The previous __getitem(self, idx: Int) is renamed as get_scalar. It gets a scalar from the buffer.
The previous __getitem(self, *idices: Int) is renamed as at, which always returns a scalar at the given coordinates.
Here are example when A is a vector, a matrix, and a 3d array. The behavior met our expectation: The number of dimension reduced equals to the number of integers as input.
Uniform the
getitem
method and allows 0d arrayRelated to Discussion #70
Variant[Slice, Int]
as the uniformed way to__getitem__
. The__getitem__
always returns an array.__getitem(self, idx: Int)
is renamed asget_scalar
. It gets a scalar from the buffer.__getitem(self, *idices: Int)
is renamed asat
, which always returns a scalar at the given coordinates.Here are example when
A
is a vector, a matrix, and a 3d array. The behavior met our expectation: The number of dimension reduced equals to the number of integers as input.Get items of array from indices
To-do: Currently it supports 1-d array. In future, expand it to high dimensional arrays.
Example: