Total Complexity | 8 |
Total Lines | 39 |
Duplicated Lines | 0 % |
1 | #!/usr/bin/env python |
||
13 | class TestLassoCannonModel(unittest.TestCase): |
||
14 | |||
15 | def setUp(self): |
||
|
|||
16 | # Initialise some faux data and labels. |
||
17 | labels = "ABCDE" |
||
18 | N_labels = len(labels) |
||
19 | N_stars = np.random.randint(1, 500) |
||
20 | N_pixels = np.random.randint(1, 10000) |
||
21 | shape = (N_stars, N_pixels) |
||
22 | |||
23 | self.valid_training_labels = np.rec.array( |
||
24 | np.random.uniform(size=(N_stars, N_labels)), |
||
25 | dtype=[(label, '<f8') for label in labels]) |
||
26 | |||
27 | self.valid_fluxes = np.random.uniform(size=shape) |
||
28 | self.valid_flux_uncertainties = np.random.uniform(size=shape) |
||
29 | |||
30 | def get_model(self): |
||
31 | return lasso.LassoCannonModel( |
||
32 | self.valid_training_labels, self.valid_fluxes, |
||
33 | self.valid_flux_uncertainties) |
||
34 | |||
35 | def test_init(self): |
||
36 | self.assertIsNotNone(self.get_model()) |
||
37 | |||
38 | def test_remind_myself_to_write_unit_tests_for_these_functions(self): |
||
39 | m = self.get_model() |
||
40 | m.label_vector = "A + B + C" |
||
41 | self.assertIsNotNone(m.label_vector) |
||
42 | |||
43 | with self.assertRaises(NotImplementedError): |
||
44 | m.train() |
||
45 | |||
46 | m._trained = True |
||
47 | with self.assertRaises(NotImplementedError): |
||
48 | m.predict(None) |
||
49 | |||
50 | with self.assertRaises(NotImplementedError): |
||
51 | m.fit([], []) |
||
52 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.