def test_intitAdaptiveList(self): features = Features(adaptive=None) self.assertEqual(features.adaptive, []) features = Features(adaptive=["feature1d", "feature2"]) self.assertEqual(features.adaptive, ["feature1d", "feature2"]) features = Features(adaptive="all") self.assertEqual(features.adaptive, [])
def test_intitFeatureList(self): features = Features(features_to_run=None) self.assertEqual(features.features_to_run, []) features = Features(features_to_run=["feature1d", "feature2"]) self.assertEqual(features.features_to_run, ["feature1d", "feature2"]) features = Features(features_to_run="all") self.assertEqual(features.features_to_run, [])
def test_intitinterpolateList(self): features = Features(interpolate=None, logger_level="error") self.assertEqual(features.interpolate, []) features = Features(interpolate=["feature1d", "feature2"]) self.assertEqual(features.interpolate, ["feature1d", "feature2"]) features = Features(interpolate="all") self.assertEqual(features.interpolate, [])
def test_add_features(self): def feature_function(time, values): return "t", "U" def feature_function2(time, values): return "t2", "U2" features = Features() features.add_features([feature_function, feature_function2], labels={"feature_function": ["x", "y"]}) time, values = features.feature_function(None, None) self.assertEqual(time, "t") self.assertEqual(values, "U") time, values = features.feature_function2(None, None) self.assertEqual(time, "t2") self.assertEqual(values, "U2") self.assertEqual(features.implemented_features(), ["feature_function", "feature_function2"]) self.assertEqual(features.features_to_run, []) self.assertEqual(features.labels, {"feature_function": ["x", "y"]})
def test_intitNewFeatures(self): def feature_function(time, values): return "t", "U" def feature_function2(time, values): return "t2", "U2" features = Features(new_features=[feature_function, feature_function2], labels={"feature_function": ["x", "y"]}, logger_level="error") time, values = features.feature_function(None, None) self.assertEqual(time, "t") self.assertEqual(values, "U") time, values = features.feature_function2(None, None) self.assertEqual(time, "t2") self.assertEqual(values, "U2") self.assertEqual(features.implemented_features(), ["feature_function", "feature_function2"]) self.assertEqual(features.features_to_run, ["feature_function", "feature_function2"]) self.assertEqual(features.labels, {"feature_function": ["x", "y"]})
def test_preprocess_args(self): features = Features() time, values, a, b = features.preprocess(self.time, self.values, 1, 2) self.assertTrue(np.array_equal(time, self.time)) self.assertTrue(np.array_equal(values, self.values)) self.assertEqual(a, 1) self.assertEqual(b, 2)
def test_preprocess_assign(self): def preprocess(time, values): return "time", "values" features = Features(preprocess=preprocess) time, values = features.preprocess(self.time, self.values) self.assertEqual(time, "time") self.assertEqual(values, "values") features = Features(preprocess=None) features.preprocess = preprocess time, values = features.preprocess(self.time, self.values) self.assertEqual(time, "time") self.assertEqual(values, "values") features = Features(preprocess=None) with self.assertRaises(TypeError): features.preprocess = 12
def test_add_feature(self): def feature_function(time, values): return "t", "U" features = Features() features.add_features(feature_function, labels={"feature_function": ["x", "y"]}) time, values = features.feature_function(None, None) self.assertEqual(time, "t") self.assertEqual(values, "U") features.features_to_run = "all" self.assertEqual(features.features_to_run, ["feature_function"]) self.assertEqual(features.labels, {"feature_function": ["x", "y"]})
def test_preprocess(self): features = Features() time, values = features.preprocess(self.time, self.values) self.assertTrue(np.array_equal(time, self.time)) self.assertTrue(np.array_equal(values, self.values))
def test_initUtility(self): new_utility_methods = ["new"] features = Features(new_utility_methods=new_utility_methods) self.assertIn("new", features.utility_methods)
def test_initNone(self): features = Features() self.assertIsInstance(features, Features)
def setUp(self): self.time = np.arange(0, 10) self.values = np.arange(0, 10) + 1 self.info = {"info": 1} self.features = Features(verbose_level="error")
def test_initNone(self): features = Features(logger_level="error") self.assertIsInstance(features, Features)
def test_set_feature(self): self.runmodel.features = Features() self.assertIsInstance(self.runmodel._features, Features) self.assertIsInstance(self.runmodel._parallel.features, Features)
def test_set_feature(self): self.runmodel.features = Features(logger_level="error") self.assertIsInstance(self.runmodel._features, Features) self.assertIsInstance(self.runmodel._parallel.features, Features)