mrpro.utils

Functions for tensor shaping, unit conversion, typing, etc.

Functions

broadcast_right(*x)

Broadcasting on the right.

fill_range_(tensor, dim)

Fill tensor in-place along a specified dimension with increasing integers.

pad_or_crop(data, new_shape[, dim, value])

Change shape of data by center cropping or symmetric padding.

ravel_multi_index(multi_index, dims)

Convert a multi-dimensional index into a flat index.

reduce_repeat(tensor[, tol, dim])

Replace dimensions with all equal values with singletons.

reduce_view(x[, dim])

Reduce expanded dimensions in a view to singletons.

reshape_broadcasted(tensor, *shape)

Reshape a tensor while preserving broadcasted (stride 0) dimensions where possible.

sliding_window(x, window_shape[, dim, ...])

Create a sliding window view into a tensor.

smap(function, tensor[, passed_dimensions])

Apply a function to a tensor serially along multiple dimensions.

split_idx(idx, blocksize[, overlap, cyclic])

Split a tensor of indices into different blocks.

unsqueeze_at(x, dim, n)

Unsqueeze multiple times at a specific dimension.

unsqueeze_left(x, n)

Unsqueeze multiple times in the leftmost dimension.

unsqueeze_right(x, n)

Unsqueeze multiple times in the rightmost dimension.

unsqueeze_tensors_at(*x, dim[, ndim])

Unsqueeze tensors at a specific dimension to the same number of dimensions.

unsqueeze_tensors_left(*x[, ndim])

Unsqueeze tensors on the left to the same number of dimensions.

unsqueeze_tensors_right(*x[, ndim])

Unsqueeze tensors on the right to the same number of dimensions.

Classes

Indexer

Custom Indexing with broadcasting.

RandomGenerator

Generate random numbers for various purposes.

TensorAttributeMixin

Create tensor attributes as buffer.

Modules

slice_profiles

Slice Profiles.

typing

Some type hints that are used in multiple places in the codebase but not part of mrpro's public API.

unit_conversion

Conversion between different units.