Skip to content

Exceptions (polykin.utils.exceptions)¤

Custom exceptions and warnings used throughout PolyKin.

This module defines a consistent set of error and warning types for common failure modes in polymerization kinetics workflows, including convergence issues, fitting failures, ODE solver problems, root-finding errors, and invalid ranges or shapes. These classes are intended to improve clarity, error handling, and diagnostics across the library.

ConvergenceError ¤

Raised when an iterative algorithm fails to converge to a solution.

Source code in src/polykin/utils/exceptions.py
16
17
class ConvergenceError(ValueError):
    """Raised when an iterative algorithm fails to converge to a solution."""

ConvergenceWarning ¤

Raised when an iterative algorithm is approaching non-convergence, indicating potential instability or slow convergence.

Source code in src/polykin/utils/exceptions.py
20
21
22
23
24
class ConvergenceWarning(Warning):
    """
    Raised when an iterative algorithm is approaching non-convergence,
    indicating potential instability or slow convergence.
    """

FitError ¤

Raised when a fitting procedure fails to find a valid solution.

Source code in src/polykin/utils/exceptions.py
27
28
class FitError(ValueError):
    """Raised when a fitting procedure fails to find a valid solution."""

FitWarning ¤

Raised when a fitting procedure produces results that may be unreliable or near failure.

Source code in src/polykin/utils/exceptions.py
31
32
33
34
35
class FitWarning(Warning):
    """
    Raised when a fitting procedure produces results that may be unreliable
    or near failure.
    """

ODESolverError ¤

Raised when an ordinary differential equation (ODE) solver fails to produce a solution.

Source code in src/polykin/utils/exceptions.py
38
39
40
41
42
class ODESolverError(ValueError):
    """
    Raised when an ordinary differential equation (ODE) solver fails to
    produce a solution.
    """

ODESolverWarning ¤

Raised when an ODE solver produces results that may be unreliable or indicate potential failure.

Source code in src/polykin/utils/exceptions.py
45
46
47
48
49
class ODESolverWarning(Warning):
    """
    Raised when an ODE solver produces results that may be unreliable
    or indicate potential failure.
    """

RangeError ¤

Raised when a value lies outside the allowed or expected range.

Source code in src/polykin/utils/exceptions.py
52
53
class RangeError(ValueError):
    """Raised when a value lies outside the allowed or expected range."""

RangeWarning ¤

Raised when a value is near or slightly outside the recommended range, but not critically so.

Source code in src/polykin/utils/exceptions.py
56
57
58
59
60
class RangeWarning(Warning):
    """
    Raised when a value is near or slightly outside the recommended range,
    but not critically so.
    """

RootSolverError ¤

Raised when a root-finding solver fails to locate a valid root.

Source code in src/polykin/utils/exceptions.py
63
64
class RootSolverError(ValueError):
    """Raised when a root-finding solver fails to locate a valid root."""

RootSolverWarning ¤

Raised when a root-finding solver encounters potential numerical issues or uncertain results.

Source code in src/polykin/utils/exceptions.py
67
68
69
70
71
class RootSolverWarning(Warning):
    """
    Raised when a root-finding solver encounters potential numerical issues
    or uncertain results.
    """

ShapeError ¤

Raised when an array or tensor has an invalid or unexpected shape.

Source code in src/polykin/utils/exceptions.py
74
75
class ShapeError(ValueError):
    """Raised when an array or tensor has an invalid or unexpected shape."""