MCPcopy Create free account
hub / github.com/activeloopai/deeplake / get_range

Method get_range

cpp/nd/array.hpp:969–986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

967
968template <typename I>
969array array::concrete_holder_<I>::get_range(int64_t start, int64_t end) const
970{
971 if constexpr (impl::has_data_member_function_v<I> && !impl::is_scalar_v<I> &&
972 !impl::has_is_none_member_variable_v<I>) {
973 auto s = impl_.shape();
974 ASSERT(!s.empty());
975 auto v =
976 std::accumulate(s.begin() + 1, s.end(), 1UL, std::multiplies<uint64_t>()) * nd::dtype_bytes(impl_.dtype());
977 auto d = impl_.data().data();
978 auto sh = icm::small_vector<int64_t>(s.begin(), s.end());
979 sh[0] = end - start;
980 static_assert(impl::has_owner_member_function_v<I>);
981 return array(impl::std_span_array_nd(
982 impl_.owner(), std::span<const uint8_t>(d + start * v, (end - start) * v), icm::shape(sh), impl_.dtype()));
983 } else {
984 throw invalid_operation("range() method is not implemented for this array.");
985 }
986}
987
988} // namespace nd
989

Callers 1

rangeMethod · 0.80

Calls 11

dtype_bytesFunction · 0.85
std_span_array_ndClass · 0.85
shapeClass · 0.85
arrayClass · 0.70
invalid_operationClass · 0.70
shapeMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
dtypeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected