Source code for statsmodels.tools.sm_exceptions

"""
Contains custom errors and warnings.

Errors should derive from Exception or another custom error. Custom errors are
only needed it standard errors, for example ValueError or TypeError, are not
accurate descriptions of the reason for the error.

Warnings should derive from either an existing warning or another custom
warning, and should usually be accompanied by a sting using the format
warning_name_doc that services as a generic message to use when the warning is
raised.
"""

import warnings


# Errors
[docs] class PerfectSeparationError(Exception): """ Error due to perfect prediction in discrete models """ pass
class MissingDataError(Exception): """ Error raised if variables contain missing values when forbidden """ pass
[docs] class X13NotFoundError(Exception): """ Error locating the X13 binary """ pass
[docs] class X13Error(Exception): """ Error when running modes using X13 """ pass
[docs] class ParseError(Exception): """ Error when parsing a docstring. """ def __str__(self): message = self.args[0] if hasattr(self, "docstring"): message = f"{message} in {self.docstring}" return message
# Warning
[docs] class X13Warning(Warning): """ Unexpected conditions when using X13 """ pass
[docs] class IOWarning(RuntimeWarning): """ Resource not deleted """ pass
[docs] class ModuleUnavailableWarning(Warning): """ Non-fatal import error """ pass
module_unavailable_doc = """ The module {0} is not available. Cannot run in parallel. """
[docs] class ModelWarning(UserWarning): """ Base internal Warning class to simplify end-user filtering """ pass
[docs] class ConvergenceWarning(ModelWarning): """ Nonlinear optimizer failed to converge to a unique solution """ pass
convergence_doc = """ Failed to converge on a solution. """
[docs] class CacheWriteWarning(ModelWarning): """ Attempting to write to a read-only cached value """ pass
[docs] class IterationLimitWarning(ModelWarning): """ Iteration limit reached without convergence """ pass
iteration_limit_doc = """ Maximum iteration reached. """
[docs] class InvalidTestWarning(ModelWarning): """ Test not applicable to model """ pass
[docs] class NotImplementedWarning(ModelWarning): """ Non-fatal function non-implementation """ pass
[docs] class OutputWarning(ModelWarning): """ Function output contains atypical values """ pass
[docs] class DomainWarning(ModelWarning): """ Variables are not compliant with required domain constraints """ pass
[docs] class ValueWarning(ModelWarning): """ Non-fatal out-of-range value given """ pass
[docs] class EstimationWarning(ModelWarning): """ Unexpected condition encountered during estimation """ pass
[docs] class SingularMatrixWarning(ModelWarning): """ Non-fatal matrix inversion affects output results """ pass
[docs] class HypothesisTestWarning(ModelWarning): """ Issue occurred when performing hypothesis test """ pass
[docs] class InterpolationWarning(ModelWarning): """ Table granularity and limits restrict interpolation """ pass
[docs] class PrecisionWarning(ModelWarning): """ Numerical implementation affects precision """ pass
[docs] class SpecificationWarning(ModelWarning): """ Non-fatal model specification issue """ pass
[docs] class HessianInversionWarning(ModelWarning): """ Hessian noninvertible and standard errors unavailable """ pass
[docs] class CollinearityWarning(ModelWarning): """ Variables are highly collinear """ pass
class PerfectSeparationWarning(ModelWarning): """ Perfect separation or prediction """ pass class InfeasibleTestError(RuntimeError): """ Test statistic cannot be computed """ pass recarray_exception = """ recarray support has been removed from statsmodels. Use pandas DataFrames for structured data. """ warnings.simplefilter("always", ModelWarning) warnings.simplefilter("always", ConvergenceWarning) warnings.simplefilter("always", CacheWriteWarning) warnings.simplefilter("always", IterationLimitWarning) warnings.simplefilter("always", InvalidTestWarning)

Last update: Dec 23, 2024