def test_detect_outlier_constant():
    """Test that a constant input produces no outliers and that warnings are raised"""

    V = np.zeros(20)  # this will trigger a runtime warning
    with pytest.warns(RuntimeWarning):
        outliers = cleansing.detect_outliers(V, 1)
    assert outliers.size == V.shape[0]
    assert outliers.sum() == 0

    V = np.zeros((20, 3))  # this will trigger a singular matrix warning
    with pytest.warns(UserWarning):
        outliers = cleansing.detect_outliers(V, 1)
    assert outliers.size == V.shape[0]
    assert outliers.sum() == 0

    V = np.zeros((20, 3))  # this will trigger a singular matrix warning
    X = np.random.randint(100, size=(20, 3))
    with pytest.warns(UserWarning):
        outliers = cleansing.detect_outliers(V, 1, coord=X, k=10)
    assert outliers.size == V.shape[0]
    assert outliers.sum() == 0
Test that a constant input produces no outliers and that warnings are raised
pysteps/tests/test_utils_cleansing.py