Ejemplo n.º 1
0
    def test_cannot_send_illegal(self):
        data = np.ones(100)
        with pytest.raises(ValueError):
            data[np.random.randint(0, len(data))] = np.nan
            smoothen(data)

        data = np.ones(10)
        with pytest.raises(ValueError):
            data[np.random.randint(0, len(data))] = np.inf
            smoothen(data)
Ejemplo n.º 2
0
    def test_returns_same_shape(self):
        data = np.ones(3)
        window_fraction = 0.3

        window_length = int(len(data) * window_fraction)
        if window_length % 2 == 0:
            window_length = max(1, window_length - 1)

        order = 1

        assert len(smoothen(data, window_fraction, order=order)) == len(data)
Ejemplo n.º 3
0
    def test_returns_same_shape(self, data, window_fraction, order):
        if np.any(np.isnan(data)) or np.any(np.isinf(data)):
            return

        window_length = int(len(data) * window_fraction)
        if window_length % 2 == 0:
            window_length = max(1, window_length - 1)

        order = order.draw(st.integers(0, window_length - 1))

        assert len(smoothen(data, window_fraction, order=order)) == len(data)
Ejemplo n.º 4
0
    def test_cannot_send_none(self):
        with pytest.raises(TypeError):
            smoothen(None)

        with pytest.raises(TypeError):
            smoothen(np.zeros(5), None)

        with pytest.raises(TypeError):
            smoothen(np.zeros(5), order=None)
Ejemplo n.º 5
0
 def test_interpolate_fn_cannot_be_none(self):
     with pytest.raises(ValueError):
         smoothen(np.zeros(5), interpolate_fn=None)
Ejemplo n.º 6
0
 def test_order_cannot_be_negative(self):
     with pytest.raises(ValueError):
         smoothen(np.zeros(5), order=-1)
Ejemplo n.º 7
0
 def test_window_fraction_too_low_warning(self):
     with pytest.warns(RuntimeWarning):
         smoothen(np.zeros(5), window_fraction=0.01)
Ejemplo n.º 8
0
    def test_window_fraction_is_fraction(self):
        window_fraction = 2.0

        with pytest.raises(ValueError):
            smoothen(np.zeros(5), window_fraction=window_fraction)
Ejemplo n.º 9
0
 def test_cannot_send_2d(self):
     with pytest.raises(ValueError):
         smoothen(np.ones((4, 3)))
Ejemplo n.º 10
0
    def test_cannot_send_empty(self):
        with pytest.raises(ValueError):
            smoothen([])

        with pytest.raises(ValueError):
            smoothen(np.array([]))
Ejemplo n.º 11
0
    def test_window_fraction_is_fraction(self, window_fraction):
        if 0 <= window_fraction <= 1:
            return

        with pytest.raises(ValueError):
            smoothen(np.zeros(5), window_fraction=window_fraction)