ndshapecheck package

Submodules

ndshapecheck.has_shape module

class ndshapecheck.has_shape.HasShape(*args, **kwargs)

Bases: Protocol

Typing for objects with .shape property.

property shape: tuple[int, ...]
Returns:

Shape of the multidimensional array as a tuple of positive integers.

ndshapecheck.shape_check module

class ndshapecheck.shape_check.ShapeCheck

Bases: object

Contains a context for maintaining consistency of symbols between subsequent shape checks.

property why: str
Returns:

The reason for the failure of a check() call.

ndshapecheck.shape_rule module

Contains code for checking a shape rule which is expressed as a string of symbols and literals.

class ndshapecheck.shape_rule.ShapeRule(context, shape_str)

Bases: object

Encapsulates a rule for a multidimensional array’s shape expressed as symbols and literals.

check(shape)
Has side-effects upon the context passed to the __init__ constructor by assigning

shape values to provided symbols.

Parameters:

shape – A multidimensional array’s shape as a tuple of integers.

Returns:

True if the provided shape matches the rule.

Module contents

class ndshapecheck.ShapeCheck

Bases: object

Contains a context for maintaining consistency of symbols between subsequent shape checks.

property why: str
Returns:

The reason for the failure of a check() call.