Source code for sciunit.errors

"""
Exception classes for SciUnit
"""


[docs]class Error(Exception): """Base class for errors in sciunit's core.""" pass
[docs]class ObservationError(Error): """Raised when an observation passed to a test is invalid.""" pass
[docs]class ParametersError(Error): """Raised when params passed to a test are invalid.""" pass
[docs]class CapabilityError(Error): """Error raised when a required capability is not provided by a model."""
[docs] def __init__(self, model, capability, details=''): self.model = model self.capability = capability if details: details = ' (%s)' % details super(CapabilityError, self).__init__( "Model '%s' does not provide required capability: '%s'%s" % (model.name, capability.__name__, details))
model = None """The model that does not have the capability.""" capability = None """The capability that is not provided."""
[docs]class PredictionError(Error): """Raised when a tests's generate_prediction chokes on a model's method"""
[docs] def __init__(self, model, method, **args): self.model = model self.method = method self.args = args super(PredictionError, self).__init__( ("During prediction, model '%s' could not successfully execute " "method '%s' with arguments %s") % (model.name, method, args))
model = None """The model that does not have the capability.""" argument = None """The argument that could not be handled."""
[docs]class InvalidScoreError(Error): """Error raised when a score is invalid.""" pass
[docs]class BadParameterValueError(Error): """Error raised when a model parameter value is unreasonable."""
[docs] def __init__(self, name, value): self.name = name self.value = value super(BadParameterValueError, self).__init__( "Parameter %s has unreasonable value of %s" % (name, value))