示例#1
0
    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, [])
示例#2
0
    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, [])
示例#3
0
    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, [])
示例#4
0
    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"]})
示例#5
0
    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"]})
示例#6
0
    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)
示例#7
0
    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
示例#8
0
    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"]})
示例#9
0
    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))
示例#10
0
    def test_initUtility(self):
        new_utility_methods = ["new"]

        features = Features(new_utility_methods=new_utility_methods)

        self.assertIn("new", features.utility_methods)
示例#11
0
    def test_initNone(self):
        features = Features()

        self.assertIsInstance(features, Features)
示例#12
0
    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")
示例#13
0
    def test_initNone(self):
        features = Features(logger_level="error")

        self.assertIsInstance(features, Features)
示例#14
0
 def test_set_feature(self):
     self.runmodel.features = Features()
     self.assertIsInstance(self.runmodel._features, Features)
     self.assertIsInstance(self.runmodel._parallel.features, Features)
示例#15
0
 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)