get_item#
- ivy.get_item(x, /, query, *, copy=None)[source]#
Gather slices from x according to query array, identical to x[query].
- Parameters:
- Return type:
- Returns:
ret – New array with the values gathered at the specified indices.
Functional Examples
>>> x = ivy.array([0, -1, 20]) >>> query = ivy.array([0, 1]) >>> print(ivy.get_item(x, query)) ivy.array([ 0, -1])
>>> x = ivy.array([[4, 5], [20, 128], [-2, -10]]) >>> query = ivy.array([[True, False], [False, False], [True, True]]) >>> print(ivy.get_item(x, query)) ivy.array([ 4, -2, -10])