Source code for gasm.utils

"""Internal utilities: warnings and validation helpers for GASM."""

from __future__ import annotations

import warnings


[docs] class GASMWarning(UserWarning): """Base class for all warnings emitted by GASM."""
[docs] class PlatformWarning(GASMWarning): """Emitted when the requested compute platform is unavailable."""
[docs] class AttributeWarning(GASMWarning): """Emitted when attribute specifications are inconsistent with the graphs."""
[docs] class ConvergenceWarning(GASMWarning): """Emitted when the iterative procedure may not have converged."""
[docs] def warn(message: str, category: type[GASMWarning] = GASMWarning) -> None: """Emit a GASM warning with a controlled stack level.""" warnings.warn(message, category, stacklevel=3)