Ejemplo n.º 1
0
 def test_outliers2(self):
     """Test that outlier detection works."""
     series = np.copy(self.series)
     series[10] = -2
     with pytest.warns(UserWarning) as record:
         series2 = purge_outliers(series)
     assert "Found 1 outliers" in record[0].message.args[0]
     assert np.all(series2[:10] == series[:10])
     assert np.all(series2[11:] == series[11:])
     np.testing.assert_almost_equal(series2[10],
                                    (series[9] + series[11]) / 2)
Ejemplo n.º 2
0
    def test_outliers3(self):
        """Test that outlier detection works."""
        series = np.copy(self.series)
        series[10] = 20
        series[11] = 20
        with pytest.warns(UserWarning) as record:
            series2 = purge_outliers(series)
        assert "Found 2 outliers" in record[0].message.args[0]

        assert np.all(series2[:10] == series[:10])
        assert np.all(series2[12:] == series[12:])

        lower = np.min([series[9], series[12]])
        upper = np.max([series[9], series[12]])
        assert np.all((series2[10:12] > lower) & (series2[10:12] < upper))