Skip to content

Exceptions

dicex.exceptions

Custom exceptions and warnings for the DiCEx package.

Exception hierarchy:

DicexError (base)
├── InvalidModelError          — model does not satisfy required protocol
├── DimensionMismatchError     — input shapes mismatch
├── InvalidParameterError      — bad hyperparameter (also a ValueError)
├── NotFittedError             — object not fitted yet (also a ValueError)
├── UnsupportedPerturbationError — perturbation type not supported (also a TypeError)
└── NumericalError             — NaN, overflow, or degenerate computation

ConvergenceWarning (UserWarning) — optimization failed to improve

ConvergenceWarning

Bases: UserWarning

Warning raised when the optimization fails to improve from the initial direction.

DicexError

Bases: Exception

Base class for all DiCEx errors.

DimensionMismatchError

Bases: DicexError

Raised when input dimensions do not match the expected shapes.

InvalidModelError

Bases: DicexError

Raised when a provided model is invalid or incompatible.

InvalidParameterError

Bases: DicexError, ValueError

Raised when a hyperparameter value is invalid.

Inherits from both DicexError and ValueError so that except ValueError in user code still catches it.

NotFittedError

Bases: DicexError, ValueError

Raised when an operation requires a fitted object.

Inherits from both DicexError and ValueError, following the scikit-learn convention for NotFittedError.

NumericalError

Bases: DicexError

Raised when a numerical issue is detected (NaN, overflow, degeneracy).

UnsupportedPerturbationError

Bases: DicexError, TypeError

Raised when a perturbation type is not supported for an operation.

Inherits from both DicexError and TypeError so that except TypeError in user code still catches it.