def test_decluster():
    """decluster an input with duplicated vectors"""

    X = np.tile(np.random.randint(100, size=(10, 2)), (3, 1))
    V = np.tile(np.random.randint(100, size=(10, 2)), (3, 1))

    X_dec, V_dec = cleansing.decluster(X, V, 20, 1)

    assert X_dec.ndim == 2
    assert V_dec.ndim == 2
    assert X_dec.shape[0] <= V_dec.shape[0]
    assert X_dec.shape[0] <= 10
    assert V_dec.shape[0] <= 10

    X_dec, V_dec = cleansing.decluster(X, V, 100, 1)
    assert X_dec.ndim == 2
    assert V_dec.ndim == 2
    assert X_dec.shape[0] == 1
    assert V_dec.shape[0] == 1
    assert np.all(X_dec == np.median(X, axis=0))
    assert np.all(V_dec == np.median(V, axis=0))
decluster an input with duplicated vectors
pysteps/tests/test_utils_cleansing.py