{ } Raw JSON

bundles / scipy 1.17.1 / scipy / signal / _arraytools / axis_slice

function

scipy.signal._arraytools:axis_slice

source: /scipy/signal/_arraytools.py :7

Signature

def   axis_slice ( a start = None stop = None step = None axis = -1 )

Summary

Take a slice along axis 'axis' from 'a'.

Parameters

a : numpy.ndarray

The array to be sliced.

start, stop, step : int or None

The slice parameters.

axis : int, optional

The axis of a to be sliced.

Notes

The keyword arguments start, stop and step are used by calling slice(start, stop, step). This implies axis_slice() does not handle its arguments the exactly the same as indexing. To select a single index k, for example, use axis_slice(a, start=k, stop=k+1) In this case, the length of the axis 'axis' in the result will be 1; the trivial dimension is not removed. (Use numpy.squeeze() to remove trivial axes.)

Examples

import numpy as np
from scipy.signal._arraytools import axis_slice
a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
axis_slice(a, start=0, stop=1, axis=1)
axis_slice(a, start=1, axis=0)

Aliases

  • scipy.signal._arraytools.axis_slice