예제 #1
0
 def test_outlier(self):
     """Test if outlier filter works."""
     filt = OutlierFilter(window_size=3,
                          precision=2,
                          entity=None,
                          radius=4.0)
     for state in self.values:
         filtered = filt.filter_state(state)
     self.assertEqual(22, filtered.state)
예제 #2
0
 def test_outlier(self):
     """Test if outlier filter works."""
     filt = OutlierFilter(window_size=3,
                          precision=2,
                          entity=None,
                          radius=4.0)
     for state in self.values:
         filtered = filt.filter_state(state)
     assert 22 == filtered.state
예제 #3
0
 def test_initial_outlier(self):
     """Test issue #13363."""
     filt = OutlierFilter(window_size=3,
                          precision=2,
                          entity=None,
                          radius=4.0)
     out = ha.State('sensor.test_monitored', 4000)
     for state in [out] + self.values:
         filtered = filt.filter_state(state)
     self.assertEqual(22, filtered.state)
예제 #4
0
 def test_initial_outlier(self):
     """Test issue #13363."""
     filt = OutlierFilter(window_size=3,
                          precision=2,
                          entity=None,
                          radius=4.0)
     out = ha.State('sensor.test_monitored', 4000)
     for state in [out]+self.values:
         filtered = filt.filter_state(state)
     assert 22 == filtered.state
예제 #5
0
    def test_outlier_step(self):
        """
        Test step-change handling in outlier.

        Test if outlier filter handles long-running step-changes correctly.
        It should converge to no longer filter once just over half the
        window_size is occupied by the new post step-change values.
        """
        filt = OutlierFilter(window_size=3,
                             precision=2,
                             entity=None,
                             radius=1.1)
        self.values[-1].state = 22
        for state in self.values:
            filtered = filt.filter_state(state)
        assert 22 == filtered.state
예제 #6
0
    def test_outlier_step(self):
        """
        Test step-change handling in outlier.

        Test if outlier filter handles long-running step-changes correctly.
        It should converge to no longer filter once just over half the
        window_size is occupied by the new post step-change values.
        """
        filt = OutlierFilter(window_size=3,
                             precision=2,
                             entity=None,
                             radius=1.1)
        self.values[-1].state = 22
        for state in self.values:
            filtered = filt.filter_state(state)
        assert 22 == filtered.state