How to use the sciunit.errors.InvalidScoreError function in sciunit

To help you get started, we’ve selected a few sciunit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scidash / sciunit / sciunit / tests.py View on Github external
def check_score_type(self, score):
        """Check that the score is the correct type for this test."""
        if not isinstance(score, (self.score_type, NoneScore, ErrorScore)):
            msg = (("Score for test '%s' is not of correct type. "
                    "The test requires type %s but %s was provided.")
                   % (self.name, self.score_type.__name__,
                      score.__class__.__name__))
            raise InvalidScoreError(msg)
github scidash / sciunit / sciunit / tests.py View on Github external
def _judge(self, prediction1, prediction2, model1, model2=None):
        # TODO: Not sure if below statement is required
        # self.last_model = model

        # 6.
        score = self.compute_score(prediction1, prediction2)
        if self.converter:
            score = self.converter.convert(score)
        # 7.
        if not isinstance(score, (self.score_type, NoneScore, ErrorScore)):
            raise InvalidScoreError(("Score for test '%s' is not of correct "
                                     "type. The test requires type %s but %s "
                                     "was provided.")
                                    % (self.name, self.score_type.__name__,
                                       score.__class__.__name__))
        # 8.
        self._bind_score(score, prediction1, prediction2, model1, model2)

        return score
github scidash / sciunit / sciunit / unit_test / error_tests.py View on Github external
def test_error_types(self):
        from sciunit.errors import CapabilityError, BadParameterValueError,\
                                   PredictionError, InvalidScoreError
        from sciunit import Model, Capability

        CapabilityError(Model(),Capability)
        PredictionError(Model(),'foo')
        InvalidScoreError()
        BadParameterValueError('x',3)
github scidash / sciunit / sciunit / scores / complete.py View on Github external
def _check_score(self, score):
        if not (0.0 <= score <= 100.0):
            raise errors.InvalidScoreError(("Score of %f must be in "
                                            "range 0.0-100.0" % score))
github scidash / sciunit / sciunit / scores / base.py View on Github external
def check_score(self, score):
        if self._allowed_types and \
          not isinstance(score, self._allowed_types+(Exception,)):
            raise InvalidScoreError(self._allowed_types_message %
                                    (type(score), self._allowed_types))
        self._check_score(score)
github scidash / sciunit / sciunit / scores / complete.py View on Github external
def _check_score(self, score):
        if isinstance(score, pq.Quantity) and score.size != 1:
            raise errors.InvalidScoreError("Score must have size 1.")
github scidash / sciunit / sciunit / scores / incomplete.py View on Github external
def __init__(self, score, related_data=None):
        if isinstance(score, str) or score is None:
            super(NoneScore, self).__init__(score, related_data=related_data)
        else:
            raise InvalidScoreError("Score must be a string or None")