コード例 #1
0
 def setUp(self):
     self.x = np.linspace(-15.0, 15.0, num=50)
     self.y = self.x
     self.model = ModelMock({"param1": 5.5})
     self.outlier = OutLierMock({
         'param1': 10,
         'param2': 5.4,
         'param3': 'hello'
     })
     self.fit1d = Fit1DMock(model=self.model,
                            outlier=self.outlier,
                            remove_outliers=False)
コード例 #2
0
class TestModel(unittest.TestCase):
    def setUp(self):
        self.m = ModelMock({"param1": 5.5, "param2": "hello"})

    def test_model_instance(self):
        self.assertTrue(isinstance(self.m, Model))

    def test_equality(self):
        new_m = ModelMock({"param1": 5.5, "param2": "hello"})
        self.assertTrue(self.m == new_m)

    def test_key_inequality(self):
        new_m = ModelMock({"param10": 5.5, "param2": "hello"})
        self.assertFalse(self.m == new_m)

    def test_value_inequality(self):
        new_m = ModelMock({"param1": 20.1, "param2": "hello"})
        self.assertFalse(self.m == new_m)

    def test_from_list(self):
        ref_list = [10, 50.2]
        new_m = ModelMock({"param1": 10, "param2": 50.2})
        self.m.from_list(ref_list)
        self.assertTrue(new_m == self.m)

    def test_to_list(self):
        ref_list = [5.5, "hello"]
        self.assertListEqual(ref_list, self.m.to_list())

    def test_from_dict(self):
        ref_dict = {"param1": "10", "param2": 50.2}
        new_m = ModelMock(ref_dict)
        self.m.from_dict(ref_dict)
        self.assertTrue(new_m == self.m)

    def test_to_dict(self):
        new_m = ModelMock({"param1": "10", "param2": 50.2})
        ref_dict = {"param1": "10", "param2": 50.2}
        self.assertDictEqual(ref_dict, new_m.to_dict())
コード例 #3
0
 def setUp(self):
     self.m = ModelMock({"param1": 5.5, "param2": "hello"})
コード例 #4
0
 def test_to_dict(self):
     new_m = ModelMock({"param1": "10", "param2": 50.2})
     ref_dict = {"param1": "10", "param2": 50.2}
     self.assertDictEqual(ref_dict, new_m.to_dict())
コード例 #5
0
 def test_from_dict(self):
     ref_dict = {"param1": "10", "param2": 50.2}
     new_m = ModelMock(ref_dict)
     self.m.from_dict(ref_dict)
     self.assertTrue(new_m == self.m)
コード例 #6
0
 def test_from_list(self):
     ref_list = [10, 50.2]
     new_m = ModelMock({"param1": 10, "param2": 50.2})
     self.m.from_list(ref_list)
     self.assertTrue(new_m == self.m)
コード例 #7
0
 def test_value_inequality(self):
     new_m = ModelMock({"param1": 20.1, "param2": "hello"})
     self.assertFalse(self.m == new_m)
コード例 #8
0
 def test_key_inequality(self):
     new_m = ModelMock({"param10": 5.5, "param2": "hello"})
     self.assertFalse(self.m == new_m)
コード例 #9
0
 def test_equality(self):
     new_m = ModelMock({"param1": 5.5, "param2": "hello"})
     self.assertTrue(self.m == new_m)
コード例 #10
0
 def setUp(self):
     self.x = np.linspace(-15.0, 15.0, num=50)
     self.y = self.x
     self.model = ModelMock({"param1": 5.5})