pynbody.util.indexing_tricks

pynbody.util.indexing_tricks#

Tricks for manipulating indexes and slices into arrays for internal use by pynbody.

Functions

chained_slice(s1, s2)

Return a slice s3 with the property that ar[s1][s2] == ar[s3]

concatenate_indexing(i1, i2)

Given either a numpy array or slice for both i1 and i2, return an object such that ar[i3] == ar[i1][i2].

index_before_slice(s, index)

Return an index array new_index such that ar[s][new_index] == ar[index].

indexing_length(sl_or_ar)

Given either an array or slice, return len(ar[sl_or_ar])

intersect_slices(s1, s2[, array_length])

Given two python slices s1 and s2, return a slice that picks out all members of s1 and s2.

relative_slice(s_relative_to, s)

Return a slice s_prime with the property that ar[s_relative_to][s_prime] == ar[s].