pynbody.util.indexing_tricks.indexing_length#
- pynbody.util.indexing_tricks.indexing_length(sl_or_ar)[source]#
Given either an array or slice, return
len(ar[sl_or_ar])
This assumes that the slice does not overrun the array, e.g. if an array
ar
is shorter than the stop index of the slicesl
then this routine will return an inaccurate result forlen(ar[sl])
.- Parameters:
sl_or_ar (slice or array-like) – The slice or array-like object to consider
- Returns:
The length of the array after slicing
- Return type:
int