示例#1
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"]})
示例#2
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"]})
示例#3
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"]})