Ejemplo n.º 1
0
def test_parallel_clustering_bad_input():
    pc = ParallelClustering(sk.cluster.DBSCAN())
    X = [np.random.random((5, 4)), np.random.random((5, 4))]

    with pytest.raises(TypeError, match="`masks` must be a boolean array."):
        pc.fit(X)

    X[1] = np.ones((6, 4), dtype=bool)
    with pytest.raises(ValueError,
                       match="`X_tot` and `masks` must have the same number"):
        pc.fit(X)
Ejemplo n.º 2
0
def test_parallel_clustering_metric_affinity_precomputed_not_implemented():
    class DummyClusterer(sk.base.BaseEstimator, sk.base.ClusterMixin):
        def __init__(self, metric="precomputed", affinity="precomputed"):
            self.metric = metric
            self.affinity = affinity

    pc = ParallelClustering(DummyClusterer())
    X = [np.random.random((5, 4)), np.ones((5, 4), dtype=bool)]

    with pytest.raises(NotImplementedError,
                       match="Behaviour when metric and affinity"):
        pc.fit(X)
Ejemplo n.º 3
0
def test_parallel_clustering_bad_clusterer():
    pc = ParallelClustering(sk.decomposition.PCA())
    X = [np.random.random((5, 4)), np.ones((5, 4), dtype=bool)]

    with pytest.raises(TypeError, match="`clusterer` must be an instance of"):
        pc.fit(X)