probly.representation.sampling.array_sample_axis_tracking

Implementation of axis tracking through NumPy-style indexing operations.

Functions

track_axis(index, special_axis, ndim)

Track the new position of a 'special' axis after a NumPy-style __getitem__ indexing operation.

probly.representation.sampling.array_sample_axis_tracking.track_axis(index, special_axis, ndim)[source]

Track the new position of a ‘special’ axis after a NumPy-style __getitem__ indexing operation.

Parameters:
  • index (Index) – The indexing object used in arr[index]. Can be a slice, int, None, list, ndarray, ellipsis, or a tuple of such.

  • special_axis (int) – Index of the axis to track (0-based) before indexing.

  • ndim (int) – Number of dimensions of the array before indexing.

Returns:

The new axis index of the special axis after indexing, or None if the axis is removed (e.g., via integer indexing).

Return type:

int | None