def __init__(self, name, description, unit, value):
     super(Indicator, self).__init__()
     self.name = name
     self.description = description
     self.unit = unit
     if not isinstance(value, numbers.Number):
         raise exception.InvalidIndicatorValue(
             _("An indicator value should be a number"))
     self.value = value
Exemple #2
0
    def validate(cls, solution):
        """Validate the given solution

        :raises: :py:class:`~.InvalidIndicatorValue` when the validation fails
        """
        indicator = cls()
        value = None
        try:
            value = getattr(solution, indicator.name)
            indicator.schema(value)
        except Exception as exc:
            LOG.exception(exc)
            raise exception.InvalidIndicatorValue(
                name=indicator.name, value=value, spec_type=type(indicator))