Пример #1
0
    def test_parsing(self):
        builder = NodeFactory.detector("test_id", "SimpleThreshold")
        builder.set_param_value("inside", False)
        builder.set_param_value("strict", False)
        builder.set_param_value("lower", 1)
        builder.set_param_value("upper", None)
        threshold = builder.build()
        self.assertEqual(str(threshold),
                         "SimpleThreshold(1,None,False,False)[test_id]")

        obj = {
            "id":
            "test_id",
            "group":
            "detector",
            "type":
            "SimpleThreshold",
            "params": [
                {
                    "id": "lower",
                    "value": 1
                },
                {
                    "id": "inside",
                    "value": False
                },
                {
                    "id": "strict",
                    "value": False
                },
            ],
        }
        th_from_json = NodeFactory.from_json(obj)
        self.assertEqual(str(threshold), str(th_from_json))
Пример #2
0
    def test_analysis_histogram_heatmap(self):
        self.maxDiff = None
        series = Series.from_array([
            [1628294400, 0],
            [1628337600, 0],
            [1628380800, 1],
            [1628424000, 1],
            [1628467200, 1],
            [1628510400, 0],
            [1628553600, 0],
            [1628596800, 0],
        ])
        factory = NodeFactory.detector('test_node', 'SimpleThreshold')
        factory.set_param_value('inside', False)
        factory.set_param_value('strict', False)
        factory.set_param_value('lower', None)
        factory.set_param_value('upper', 1)
        factory.add_source(InputRef('input'))
        node = factory.build()

        pipeline = Pipeline([node])
        analyzer = Analyzer(pipeline=pipeline, debug=True)
        analysis = analyzer.analyze({'input': series})
        actual_output = analysis.output_format()

        expected_file = os.path.join(os.path.dirname(__file__), 'resources/analysis/expected_histogram_heatmap.json')
        # Uncomment to fix test
        # print(json.dumps(actual_output, indent=2), file=open(expected_file, 'w'))
        expected_output = json.loads(Path(expected_file).read_text())
        self.assertEqual(expected_output, actual_output)
Пример #3
0
 def prepare_factory(self):
     factory = NodeFactory.detector('test', 'Quantile')
     factory.add_source(InputRef('input'))
     return factory
Пример #4
0
 def prepare_factory(self):
     factory = NodeFactory.detector('test', 'SimpleThreshold')
     factory.add_source(InputRef('input'))
     return factory