def get_axis ( array , axis , slice_num ) : slice_list = [ slice ( None ) ] * array . ndim slice_list [ axis ] = slice_num slice_data = array [ tuple ( slice_list ) ] . T # transpose for proper orientation return slice_data
multi axis slicing python
Returns a fixed axis
def get_axis(array, axis, slice_num):
    """Returns a fixed axis"""

    slice_list = [slice(None)] * array.ndim
    slice_list[axis] = slice_num
    slice_data = array[tuple(slice_list)].T  # transpose for proper orientation

    return slice_data