Ejemplo n.º 1
0
    def setUp(self):
        self.myModel1 = ConstModel(100.0, "Model1")
        self.myModel2 = ConstModel(110.0, "Model2")

        class NumberTest_M2M(TestM2M):
            """Dummy Test"""

            score_type = FloatScore
            description = "Tests the parameter 'value' between two models"

            def __init__(self, observation=None, name="ValueTest-M2M"):
                TestM2M.__init__(self, observation, name)
                self.required_capabilities += (ProducesNumber, )

            def generate_prediction(self, model, verbose=False):
                """Implementation of sciunit.Test.generate_prediction."""
                prediction = model.produce_number()
                return prediction

            def compute_score(self, prediction1, prediction2):
                """Implementation of sciunit.Test.score_prediction."""
                score = FloatScore(prediction1 - prediction2)
                score.description = "Difference between model predictions"
                return score

        self.NumberTest_M2M = NumberTest_M2M
Ejemplo n.º 2
0
    def test_regular_models(self):
        from sciunit.models.examples\
            import ConstModel, UniformModel, SharedModel

        m = ConstModel(3)
        self.assertEqual(m.produce_number(),3)

        m = UniformModel(3,4)
        self.assertTrue(3 < m.produce_number() < 4)
Ejemplo n.º 3
0
    def test_regular_models(self):
        from sciunit.models.examples\
            import ConstModel, UniformModel, SharedModel

        m = ConstModel(3)
        self.assertEqual(m.produce_number(),3)

        m = UniformModel(3,4)
        self.assertTrue(3 < m.produce_number() < 4)
Ejemplo n.º 4
0
    def test_versioned(self):
        from sciunit.models.examples import ConstModel

        m = ConstModel(37)
        print("Commit hash is %s" % m.version)
        print("Remote URL is %s" % m.remote_url)
        self.assertTrue('sciunit' in m.remote_url)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
    def test_regular_models(self):
        from sciunit.models.examples import (
            ConstModel,
            PersistentUniformModel,
            SharedModel,
            UniformModel,
        )

        m = ConstModel(3)
        self.assertEqual(m.produce_number(), 3)

        m = UniformModel(3, 4)
        self.assertTrue(3 < m.produce_number() < 4)

        m = PersistentUniformModel(3, 4)
        m.run()
        self.assertTrue(3 < m.produce_number() < 4)