take#

Fully qualified name: isaacsim::common::array::take

Array isaacsim::common::array::take(
const Array &a,
const std::vector<int64_t> &indices,
const std::optional<int64_t> &axis = std::nullopt,
)#

Gathers elements along a single axis by index.

Selects the positions listed in indices along axis, so the result has the operand’s shape with that axis resized to indices.size(). When axis is omitted the operand is flattened first and the result is 1-D. Negative entries in indices count from the end of the axis, and a negative axis counts from the last axis. Indices may repeat, which duplicates elements, and may be empty, which produces a zero-sized axis. A 0-D operand is treated as 1-D of size 1 whether or not an axis is given. The result keeps the operand’s dtype and device, and holds a copy rather than a view of the elements.

Parameters:
  • a – [in] Operand.

  • indices – [in] Positions to gather along axis.

  • axis – [in] Axis to gather along, or std::nullopt to gather from the flattened operand.

Throws:
  • std::invalid_argument – if axis is out of range for the operand.

  • std::out_of_range – if any entry of indices is out of range for that axis. The two are kept distinct as NumPy does, which reports an out-of-range axis as an AxisError (a ValueError) but an out-of-range index as an IndexError.

Returns:

A new Array holding the gathered elements.