skshapes package

Scikit-Shapes: shape analysis in python.

Subpackages

Submodules

skshapes.errors module

Custom errors for the skshapes package.

exception skshapes.errors.DeviceError

Bases: Exception

Raised when devices mismatch.

exception skshapes.errors.InputStructureError

Bases: Exception

Raised when the input structure is not valid.

exception skshapes.errors.NotFittedError

Bases: Exception

Raised when the model is not fitted.

exception skshapes.errors.ShapeError

Bases: Exception

Raised when an input has an invalid shape.

skshapes.globals module

This modules contains global variables for the skshapes package

skshapes.types module

Types aliases and utility functions for scikit-shapes.

class skshapes.types.CoarseToFinePolicy(smoothing: Literal['constant', 'point_convolution', 'mesh_convolution'] = 'constant', n_smoothing_steps: int = 1)

Bases: NamedTuple

Parameters for the coarse to fine propagation scheme.

Parameters:
  • smoothing (str, default="constant") – The smoothing operation to use when propagating the signal from the coarse to the fine resolutions. Possible values are “constant”, “point_convolution” and “mesh_convolution”.

  • n_smoothing_steps (int, default=1) – The number of smoothing steps to perform when propagating the signal from the coarse to the fine resolutions.

n_smoothing_steps: int

Alias for field number 1

smoothing: Literal['constant', 'point_convolution', 'mesh_convolution']

Alias for field number 0

class skshapes.types.FineToCoarsePolicy(reduce: Literal['mean', 'max', 'min', 'sum'] = 'mean')

Bases: NamedTuple

Parameters for the fine to coarse propagation scheme.

Parameters:

reduce (str, default="mean") – The reduction operation to use when propagating the signal from the fine to the coarse resolutions. Possible values are “mean”, “max”, “min” and “sum”.

reduce: Literal['mean', 'max', 'min', 'sum']

Alias for field number 0

class skshapes.types.MorphingOutput(morphed_shape=None, regularization=None, path=None, path_length=None, **kwargs)

Bases: object

Class containing the result of the morphing algorithms.

It acts as a container for the result of the morphing algorithms. It contains the morphed shape, the regularization parameter (if any), the path (if any), the path length (if any) and eventually other attributes.

Parameters:
  • morphed_shape (polydata_type | image_type | None) – the morphed shape

  • regularization (Float32[Tensor, ''] | None) – the regularization parameter

  • path (list[polydata_type | image_type] | None) – the path (list of shapes)

  • path_length (Float32[Tensor, ''] | None) – the length of the path

  • kwargs – other attributes (if any)

class skshapes.types.image_type

Bases: object

Class for image shapes.

class skshapes.types.polydata_type

Bases: object

Class for polydata shapes.

skshapes.utils module

Utility functions for the skshapes package.

skshapes.utils.diagonal_ranges(batch_x=None, batch_y=None)

Encode the block-diagonal structure associated to a batch vector.

skshapes.utils.ranges_slices(batch)

Helper function for the diagonal ranges function.

skshapes.utils.scatter(src, index, reduce='mean', min_length=None, blank_value=0)

Scatter operation on a tensor.

This function is a wrapper around the pytorch scatter function. Available reduce operations are “sum”, “min”, “max”, “mean”. It is compatible with automatic differentiation.

Parameters:
  • src ('] | ']) – The source tensor.

  • index (Int64[Tensor, '_']) – The indices of the elements to scatter.

  • reduce (Literal['sum', 'min', 'max', 'mean']) – The reduce operation to apply. Defaults to “mean”.

  • min_length (int | None) – The minimum length of the output tensor. If None it is set according to the highest index value.

  • blank_value (int | float) – The value to set for the elements of the output tensor that are not referenced by the index tensor.