Exemplo n.º 1
0
def test_color_different_size_input():
    data = np.array([[0., 0.], [0.1, 0.1], [0.2, 0.2], [0.2, 0.8], [0.1, 0.9],
                     [0., 1.], [0.8, 0.8], [0.9, 0.9], [1., 1.]])

    target = np.array([0, 1, 2])

    t = Topology()
    t.fit_transform(data, metric=None, lens=None)
    t.map(resolution=2, overlap=0.3, clusterer=None)

    with pytest.raises(ValueError):
        t.color(target, dtype="categorical", ctype="rgb", normalized=False)
Exemplo n.º 2
0
def test_color_dtype():
    data = np.array([[0., 0.], [0.1, 0.1], [0.2, 0.2], [0.2, 0.8], [0.1, 0.9],
                     [0., 1.], [0.8, 0.8], [0.9, 0.9], [1., 1.]])

    target = np.array([[0], [0], [0], [1], [1], [1], [2], [2], [2]])

    t = Topology()
    t.fit_transform(data, metric=None, lens=None)
    t.map(resolution=2, overlap=0.3, clusterer=None)

    with pytest.raises(Exception):
        t.color(target, dtype="somecategory", ctype="rgb", normalized=False)
Exemplo n.º 3
0
def test_color_numerical_rgb():
    data = np.array([[0., 0.], [0.1, 0.1], [0.2, 0.2], [0.2, 0.8], [0.1, 0.9],
                     [0., 1.], [0.8, 0.8], [0.9, 0.9], [1., 1.]])

    target = np.array([[0], [0], [0], [1], [1.1], [0.9], [2], [2], [2]])

    t = Topology()
    t.fit_transform(data, metric=None, lens=None)

    clusterer = DBSCAN(eps=0.2, min_samples=3)
    t.map(resolution=2, overlap=0.3, clusterer=clusterer)

    t.color(target, dtype="numerical", ctype="rgb", normalized=False)

    test_color = ['#0000b2', '#00b200', '#b2b200']

    assert t.colorlist == test_color
Exemplo n.º 4
0
def test_color_categorical_gray():
    data = np.array([[0., 0.], [0.1, 0.1], [0.2, 0.2], [0.2, 0.8], [0.1, 0.9],
                     [0., 1.], [0.8, 0.8], [0.9, 0.9], [1., 1.]])

    target = np.array([[0], [0], [0], [1], [1], [1], [2], [2], [2]])

    t = Topology()
    t.fit_transform(data, metric=None, lens=None)

    clusterer = DBSCAN(eps=0.2, min_samples=3)
    t.map(resolution=2, overlap=0.3, clusterer=clusterer)

    t.color(target, dtype="categorical", ctype="gray", normalized=False)

    test_color = ['#dcdcdc', '#787878', '#464646']

    assert t.colorlist == test_color