ezmsg.sigproc.slicer#

Functions

parse_slice(s, axinfo=None)[source]#

Parses a string representation of a slice and returns a tuple of slice objects.

  • “” -> slice(None, None, None) (take all)

  • “:” -> slice(None, None, None)

  • ‘“none”` (case-insensitive) -> slice(None, None, None)

  • “{start}:{stop}” or {start}:{stop}:{step} -> slice(start, stop, step)

  • “5” (or any integer) -> (5,). Take only that item.

    applying this to a ndarray or AxisArray will drop the dimension.

  • A comma-separated list of the above -> a tuple of slices | ints

  • A comma-separated list of values and axinfo is provided and is a CoordinateAxis -> a tuple of ints

Parameters:
  • s (str) – The string representation of the slice.

  • axinfo (CoordinateAxis | None) – (Optional) If provided, and of type CoordinateAxis, and s is a comma-separated list of values, then the values in s will be checked against the values in axinfo.data.

Returns:

A tuple of slice objects and/or ints.

Return type:

tuple[slice | int, …]

slicer(selection='', axis=None)[source]#

Slice along a particular axis.

Parameters:
Returns:

SlicerTransformer

Return type:

SlicerTransformer

Classes

class Slicer(*args, settings=None, **kwargs)[source]#

Bases: BaseTransformerUnit[SlicerSettings, AxisArray, AxisArray, SlicerTransformer]

Parameters:

settings (Settings | None)

SETTINGS#

alias of SlicerSettings

class SlicerSettings(selection: str = '', axis: str | None = None)[source]#

Bases: Settings

Parameters:
  • selection (str)

  • axis (str | None)

selection: str = ''#

See ezmsg.sigproc.slicer.parse_slice for details.

Type:

selection

axis: str | None = None#

The name of the axis to slice along. If None, the last axis is used.

__init__(selection='', axis=None)#
Parameters:
  • selection (str)

  • axis (str | None)

Return type:

None

class SlicerState[source]#

Bases: object

slice_: slice | int | ndarray[tuple[Any, ...], dtype[_ScalarT]] | None = None#
new_axis: AxisBase | None = None#
b_change_dims: bool = False#
class SlicerTransformer(*args, **kwargs)[source]#

Bases: BaseStatefulTransformer[SlicerSettings, AxisArray, AxisArray, SlicerState]

parse_slice(s, axinfo=None)[source]#

Parses a string representation of a slice and returns a tuple of slice objects.

  • “” -> slice(None, None, None) (take all)

  • “:” -> slice(None, None, None)

  • ‘“none”` (case-insensitive) -> slice(None, None, None)

  • “{start}:{stop}” or {start}:{stop}:{step} -> slice(start, stop, step)

  • “5” (or any integer) -> (5,). Take only that item.

    applying this to a ndarray or AxisArray will drop the dimension.

  • A comma-separated list of the above -> a tuple of slices | ints

  • A comma-separated list of values and axinfo is provided and is a CoordinateAxis -> a tuple of ints

Parameters:
  • s (str) – The string representation of the slice.

  • axinfo (CoordinateAxis | None) – (Optional) If provided, and of type CoordinateAxis, and s is a comma-separated list of values, then the values in s will be checked against the values in axinfo.data.

Returns:

A tuple of slice objects and/or ints.

Return type:

tuple[slice | int, …]

class SlicerSettings(selection: str = '', axis: str | None = None)[source]#

Bases: Settings

Parameters:
  • selection (str)

  • axis (str | None)

selection: str = ''#

See ezmsg.sigproc.slicer.parse_slice for details.

Type:

selection

axis: str | None = None#

The name of the axis to slice along. If None, the last axis is used.

__init__(selection='', axis=None)#
Parameters:
  • selection (str)

  • axis (str | None)

Return type:

None

class SlicerState[source]#

Bases: object

slice_: slice | int | ndarray[tuple[Any, ...], dtype[_ScalarT]] | None = None#
new_axis: AxisBase | None = None#
b_change_dims: bool = False#
class SlicerTransformer(*args, **kwargs)[source]#

Bases: BaseStatefulTransformer[SlicerSettings, AxisArray, AxisArray, SlicerState]

class Slicer(*args, settings=None, **kwargs)[source]#

Bases: BaseTransformerUnit[SlicerSettings, AxisArray, AxisArray, SlicerTransformer]

Parameters:

settings (Settings | None)

SETTINGS#

alias of SlicerSettings

slicer(selection='', axis=None)[source]#

Slice along a particular axis.

Parameters:
Returns:

SlicerTransformer

Return type:

SlicerTransformer