Skip to content

brahmap.base.ShapeError

Bases: Exception

An exception class for handling array or operator shape mismatch errors.

This exception is raised when defining a linear operator with an invalid shape or when multiplying a linear operator by a vector of an incompatible shape.

Parameters:

Name Type Description Default
value str

The descriptive error message detailing the shape mismatch

required
Source code in brahmap/base/misc.py
class ShapeError(Exception):
    """An exception class for handling array or operator shape mismatch errors.

    This exception is raised when defining a linear operator with an invalid shape
    or when multiplying a linear operator by a vector of an incompatible shape.

    Parameters
    ----------
    value : str
        The descriptive error message detailing the shape mismatch
    """

    def __init__(self, value: str) -> None:
        super(ShapeError, self).__init__()
        self.value = value

    def __str__(self):
        return repr(self.value)