<commit_before>
class MatrixError(Exception):
    """ An exception related to a matrix.

    This is the base exception for all exceptions in this package.
    """

    def __init__(self, matrix=None, message=None):
        self.matrix = matrix
        if message is None:
            message = 'Error with matrix{matrix_decription}!'
        message = message.format(matrix_decription=self._matrix_decription)
        self.message = message
        super().__init__(message)

    def __str__(self):
        return self.message

    @property
    def _matrix_decription(self):
        if self.matrix is not None:
            return ' with shape {}'.format(self.matrix.shape)
        else:
            return ''


class MatrixNotSquareError(MatrixError):
    """ A matrix is not a square matrix although this is required. """

    def __init__(self, matrix=None):
        message = 'Matrix{matrix_decription} is not a square matrix.'
        super().__init__(matrix=matrix, message=message)


class MatrixNotFiniteError(MatrixError):
    """ A matrix has non-finite entries although a finite matrix is required. """

    def __init__(self, matrix=None, message=None):
        if message is None:
            message = 'Matrix{matrix_decription} has not finite entries.'
        super().__init__(matrix=matrix, message=message)


class MatrixDecompositionNotFiniteError(MatrixNotFiniteError):
    """ A decomposition of a matrix has non-finite entries although a finite matrix is required. """

    def __init__(self, decomposition=None):
        # compose message
        message = 'Decomposition '
        if decomposition is not None:
            self.decomposition = decomposition
            message += str(decomposition) + ' '
        message += 'has non-finite entries.'
        super().__init__(message=message)


class MatrixNoDecompositionPossibleError(MatrixError):
    """ The matrix decomposition is not possible for this matrix. """

    def __init__(self, matrix=None, decomposition_decription=None, message=None):
        # compose message
        total_message = 'It was not possible to compute a '
        if decomposition_decription is not None:
            total_message += decomposition_decription + ' '
        total_message += 'decomposition for matrix{matrix_decription}.'
        if message is not None:
            total_message += message
        super().__init__(matrix=matrix, message=total_message)


class MatrixNoDecompositionPossibleTooManyEntriesError(MatrixNoDecompositionPossibleError):
    """ The matrix decomposition is not possible for this matrix because it would have too many entries. """
<commit_msg>ENH: matrix.errors: MatrixDecompositionSingularError added<commit_after>
class MatrixError(Exception):
    """ An exception related to a matrix.

    This is the base exception for all exceptions in this package.
    """

    def __init__(self, matrix=None, message=None):
        self.matrix = matrix
        if message is None:
            message = 'Error with matrix{matrix_decription}!'
        message = message.format(matrix_decription=self._matrix_decription)
        self.message = message
        super().__init__(message)

    def __str__(self):
        return self.message

    @property
    def _matrix_decription(self):
        if self.matrix is not None:
            return ' with shape {}'.format(self.matrix.shape)
        else:
            return ''


class MatrixNotSquareError(MatrixError):
    """ A matrix is not a square matrix although this is required. """

    def __init__(self, matrix=None):
        message = 'Matrix{matrix_decription} is not a square matrix.'
        super().__init__(matrix=matrix, message=message)


class MatrixNotFiniteError(MatrixError):
    """ A matrix has non-finite entries although a finite matrix is required. """

    def __init__(self, matrix=None, message=None):
        if message is None:
            message = 'Matrix{matrix_decription} has not finite entries.'
        super().__init__(matrix=matrix, message=message)


class MatrixDecompositionNotFiniteError(MatrixNotFiniteError):
    """ A decomposition of a matrix has non-finite entries although a finite matrix is required. """

    def __init__(self, decomposition=None):
        # compose message
        message = 'Decomposition '
        if decomposition is not None:
            self.decomposition = decomposition
            message += str(decomposition) + ' '
        message += 'has non-finite entries.'
        super().__init__(message=message)


class MatrixDecompositionSingularError(MatrixError):
    """ A decomposition represents a singular matrix although a non-singular matrix is required. """

    def __init__(self, decomposition=None):
        # compose message
        message = 'Decomposition '
        if decomposition is not None:
            self.decomposition = decomposition
            message += str(decomposition) + ' '
        message += 'represents a singular matrix.'
        super().__init__(message=message)


class MatrixNoDecompositionPossibleError(MatrixError):
    """ The matrix decomposition is not possible for this matrix. """

    def __init__(self, matrix=None, decomposition_decription=None, message=None):
        # compose message
        total_message = 'It was not possible to compute a '
        if decomposition_decription is not None:
            total_message += decomposition_decription + ' '
        total_message += 'decomposition for matrix{matrix_decription}.'
        if message is not None:
            total_message += message
        super().__init__(matrix=matrix, message=total_message)


class MatrixNoDecompositionPossibleTooManyEntriesError(MatrixNoDecompositionPossibleError):
    """ The matrix decomposition is not possible for this matrix because it would have too many entries. """

{'fraction_non_alphanumeric': 0.08526731992435964, 'fraction_numerical': 0.0, 'mean_word_length': 3.1145685997171144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1253984', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1412, 'n_words': 463}