How to use the sciunit.scores.BooleanScore 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 / unit_test / test_tests.py View on Github external
def test_rangetest(self):
        range_2_3_test = RangeTest(observation=[2, 3])
        one_model = ConstModel(2.5)
        self.assertTrue(range_2_3_test.check_capabilities(one_model))
        score = range_2_3_test.judge(one_model)
        self.assertTrue(isinstance(score, BooleanScore))
        self.assertEqual(score.score,True)
        self.assertTrue(score.test is range_2_3_test)
        self.assertTrue(score.model is one_model)
github scidash / sciunit / sciunit / unit_test / core_tests.py View on Github external
def test_regular_score_types(self):
        from sciunit.scores import BooleanScore,FloatScore,RatioScore,\
                                   ZScore,CohenDScore,PercentScore
        from sciunit.tests import RangeTest
        
        BooleanScore(True)
        BooleanScore(False)
        score = BooleanScore.compute(5,5)
        self.assertEqual(score.sort_key,1)
        score = BooleanScore.compute(4,5)
        self.assertEqual(score.sort_key,0)
        
        t = RangeTest([2,3])
        score.test = t
        score.describe()
        score.description = "Lorem Ipsum"
        score.describe()

        score = FloatScore(3.14)
        obs = np.array([1.0,2.0,3.0])
        pred = np.array([1.0,2.0,4.0])
        score = FloatScore.compute_ssd(obs,pred)
        self.assertEqual(score.score,1.0)
github scidash / sciunit / sciunit / unit_test / core_tests.py View on Github external
def test_converters(self):
        from sciunit.converters import NoConversion,LambdaConversion,\
                                       AtMostToBoolean,AtLeastToBoolean,\
                                       RangeToBoolean
        from sciunit.scores import BooleanScore,ZScore

        old_score = ZScore(1.3)
        new_score = NoConversion().convert(old_score)
        self.assertEqual(old_score,new_score)
        new_score = LambdaConversion(lambda x:x.score**2).convert(old_score)
        self.assertEqual(old_score.score**2,new_score.score)
        new_score = AtMostToBoolean(3).convert(old_score)
        self.assertEqual(new_score,BooleanScore(True))
        new_score = AtMostToBoolean(1).convert(old_score)
        self.assertEqual(new_score,BooleanScore(False))
        new_score = AtLeastToBoolean(1).convert(old_score)
        self.assertEqual(new_score,BooleanScore(True))
        new_score = AtLeastToBoolean(3).convert(old_score)
        self.assertEqual(new_score,BooleanScore(False))
        new_score = RangeToBoolean(1,3).convert(old_score)
        self.assertEqual(new_score,BooleanScore(True))
        new_score = RangeToBoolean(3,5).convert(old_score)
        self.assertEqual(new_score,BooleanScore(False))
        self.assertEqual(new_score.raw,str(old_score.score))
github scidash / sciunit / sciunit / unit_test / converter_tests.py View on Github external
RangeToBoolean
        from sciunit.scores import BooleanScore,ZScore

        old_score = ZScore(1.3)
        new_score = NoConversion().convert(old_score)
        self.assertEqual(old_score,new_score)
        new_score = LambdaConversion(lambda x:x.score**2).convert(old_score)
        self.assertEqual(old_score.score**2,new_score.score)
        new_score = AtMostToBoolean(3).convert(old_score)
        self.assertEqual(new_score,BooleanScore(True))
        new_score = AtMostToBoolean(1).convert(old_score)
        self.assertEqual(new_score,BooleanScore(False))
        new_score = AtLeastToBoolean(1).convert(old_score)
        self.assertEqual(new_score,BooleanScore(True))
        new_score = AtLeastToBoolean(3).convert(old_score)
        self.assertEqual(new_score,BooleanScore(False))
        new_score = RangeToBoolean(1,3).convert(old_score)
        self.assertEqual(new_score,BooleanScore(True))
        new_score = RangeToBoolean(3,5).convert(old_score)
        self.assertEqual(new_score,BooleanScore(False))
        self.assertEqual(new_score.raw,str(old_score.score))
github scidash / sciunit / sciunit / unit_test / score_tests.py View on Github external
def test_regular_score_types_2(self):
        BooleanScore(True)
        BooleanScore(False)
        score = BooleanScore.compute(5, 5)
        self.assertEqual(score.norm_score, 1)
        score = BooleanScore.compute(4, 5)
        self.assertEqual(score.norm_score, 0)

        t = RangeTest([2, 3])
        score.test = t
        score.describe()
        score.description = "Lorem Ipsum"
        score.describe()

        score = FloatScore(3.14)
        obs = np.array([1.0, 2.0, 3.0])
        pred = np.array([1.0, 2.0, 4.0])
        score = FloatScore.compute_ssd(obs, pred)
github scidash / sciunit / sciunit / unit_test / score_tests.py View on Github external
def test_regular_score_types_2(self):
        BooleanScore(True)
        BooleanScore(False)
        score = BooleanScore.compute(5, 5)
        self.assertEqual(score.norm_score, 1)
        score = BooleanScore.compute(4, 5)
        self.assertEqual(score.norm_score, 0)

        t = RangeTest([2, 3])
        score.test = t
        score.describe()
        score.description = "Lorem Ipsum"
        score.describe()

        score = FloatScore(3.14)
        obs = np.array([1.0, 2.0, 3.0])
        pred = np.array([1.0, 2.0, 4.0])
        score = FloatScore.compute_ssd(obs, pred)
        self.assertEqual(score.score, 1.0)

        RatioScore(1.2)
        score = RatioScore.compute({'mean': 4., 'std': 1.}, {'value': 2.})
github scidash / sciunit / sciunit / unit_test / core_tests.py View on Github external
def test_regular_score_types(self):
        from sciunit.scores import BooleanScore,FloatScore,RatioScore,\
                                   ZScore,CohenDScore,PercentScore
        from sciunit.tests import RangeTest
        
        BooleanScore(True)
        BooleanScore(False)
        score = BooleanScore.compute(5,5)
        self.assertEqual(score.sort_key,1)
        score = BooleanScore.compute(4,5)
        self.assertEqual(score.sort_key,0)
        
        t = RangeTest([2,3])
        score.test = t
        score.describe()
        score.description = "Lorem Ipsum"
        score.describe()

        score = FloatScore(3.14)
        obs = np.array([1.0,2.0,3.0])
        pred = np.array([1.0,2.0,4.0])
        score = FloatScore.compute_ssd(obs,pred)
github scidash / sciunit / sciunit / converters.py View on Github external
def _convert(self, score):
        return BooleanScore(bool(score <= self.cutoff))