Beispiel #1
0
 def setUp(self):
     self.x = np.array([1, 2, 3, 4])
     self.y = np.array([10, 20, 30, 40])
     self.model = ModelMock({"param1": 5.5})
     self.outlier = OutLierMock({
         'param1': 10,
         'param2': 5.4,
         'param3': 'hello'
     })
     self.fit1d = Fit1DMock(outlier=self.outlier, remove_outliers=False)
Beispiel #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())
Beispiel #3
0
 def setUp(self):
     self.x = np.array([1, 2, 3, 4])
     self.y = np.array([10, 20, 30, 40])
     self.model = ModelMock({"param1": 5.5})
Beispiel #4
0
 def setUp(self):
     self.m = ModelMock({"param1": 5.5, "param2": "hello"})
Beispiel #5
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())
Beispiel #6
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)
Beispiel #7
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)
Beispiel #8
0
 def test_value_inequality(self):
     new_m = ModelMock({"param1": 20.1, "param2": "hello"})
     self.assertFalse(self.m == new_m)
Beispiel #9
0
 def test_key_inequality(self):
     new_m = ModelMock({"param10": 5.5, "param2": "hello"})
     self.assertFalse(self.m == new_m)
Beispiel #10
0
 def test_equality(self):
     new_m = ModelMock({"param1": 5.5, "param2": "hello"})
     self.assertTrue(self.m == new_m)
Beispiel #11
0
 def _calc_fit(self):
     self._fit_data.model = ModelMock({"param1": 5.5})
Beispiel #12
0
 def setUp(self):
     self.x = np.linspace(-15.0, 15.0, num=50)
     self.y = self.x
     self.model = ModelMock({"param1": 5.5})