napari.utils.transforms.TransformChain#

class napari.utils.transforms.TransformChain(transforms: Iterable[Transform] | None = None)[source]#

Bases: EventedList[_T], Transform, Generic[_T]

Methods

append(value)

S.append(value) -- append value to the end of the sequence

clear()

compose(transform)

Return the composite of this transform and the provided one.

copy()

Return a shallow copy of the list.

count(value)

expand_dims(axes)

Return a transform chain with added axes for non-visible dimensions.

extend(values)

S.extend(iterable) -- extend sequence by appending elements from the iterable

index(value[, start, stop])

Return first index of value.

insert(index, value)

Insert value before index.

move(src_index[, dest_index])

Insert object at src_index before dest_index.

move_multiple(sources[, dest_index])

Move a batch of sources indices, to a single destination.

pop([index])

Raise IndexError if list is empty or index is out of range.

remove(value)

S.remove(value) -- remove first occurrence of value.

reverse()

Reverse list IN PLACE.

set_slice(axes)

Return a transform chain subset to the visible dimensions.

Attributes

changed

inverse

Return the inverse transform chain.

simplified

Return the composite of the transforms inside the transform chain.

Details

append(value)#

S.append(value) – append value to the end of the sequence

clear() None -- remove all items from S#
compose(transform: Transform) Transform#

Return the composite of this transform and the provided one.

copy() TypedMutableSequence[_T]#

Return a shallow copy of the list.

count(value) integer -- return number of occurrences of value#
expand_dims(axes: Sequence[int]) TransformChain[source]#

Return a transform chain with added axes for non-visible dimensions.

Parameters:

axes (Sequence[int]) – Location of axes to expand the current transform with. Passing a list allows expansion to occur at specific locations and for expand_dims to be like an inverse to the set_slice method.

Returns:

Resulting transform chain.

Return type:

TransformChain

extend(values)#

S.extend(iterable) – extend sequence by appending elements from the iterable

index(value: _L, start: int = 0, stop: int | None = None) int#

Return first index of value.

Parameters:
  • value (Any) – A value to lookup. If type(value) is in the lookups functions provided for this class, then values in the list will be searched using the corresponding lookup converter function.

  • start (int, optional) – The starting index to search, by default 0

  • stop (int, optional) – The ending index to search, by default None

Returns:

The index of the value

Return type:

int

Raises:

ValueError – If the value is not present

insert(index: int, value: _T) None#

Insert value before index.

property inverse: TransformChain#

Return the inverse transform chain.

move(src_index: int, dest_index: int = 0) bool#

Insert object at src_index before dest_index.

Both indices refer to the list prior to any object removal (pre-move space).

move_multiple(sources: Iterable[int | slice], dest_index: int = 0) int#

Move a batch of sources indices, to a single destination.

Note, if dest_index is higher than any of the sources, then the resulting position of the moved objects after the move operation is complete will be lower than dest_index.

Parameters:
  • sources (Sequence[int or slice]) – A sequence of indices

  • dest_index (int, optional) – The destination index. All sources will be inserted before this index (in pre-move space), by default 0… which has the effect of “bringing to front” everything in sources, or acting as a “reorder” method if sources contains all indices.

Returns:

The number of successful move operations completed.

Return type:

int

Raises:

TypeError – If the destination index is a slice, or any of the source indices are not int or slice.

pop([index]) item -- remove and return item at index (default last).#

Raise IndexError if list is empty or index is out of range.

remove(value)#

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse() None#

Reverse list IN PLACE.

set_slice(axes: Sequence[int]) TransformChain[source]#

Return a transform chain subset to the visible dimensions.

Parameters:

axes (Sequence[int]) – Axes to subset the current transform chain with.

Returns:

Resulting transform chain.

Return type:

TransformChain

property simplified: _T#

Return the composite of the transforms inside the transform chain.

Raises:

ValueError – If the transform chain is empty.