File: test_plot.py

package info (click to toggle)
umap-learn 0.5.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,468 kB
  • sloc: python: 9,458; sh: 87; makefile: 20
file content (51 lines) | stat: -rw-r--r-- 1,836 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import numpy as np
import pytest
import umap

# Globals, used for all the tests
SEED = 189212  # 0b101110001100011100
np.random.seed(SEED)

try:
    from umap import plot

    IMPORT_PLOT = True
except ImportError:
    IMPORT_PLOT = False

plot_only = pytest.mark.skipif(not IMPORT_PLOT, reason="umap plot not found.")


@pytest.fixture(scope="session")
def mapper(iris):
    return umap.UMAP(n_epochs=100).fit(iris.data)


# These tests requires revision: Refactoring is
# needed as there is no assertion nor
# property verification.
@plot_only
@pytest.mark.xfail(run=False)
def test_plot_runs_at_all(mapper, iris, iris_selection):
    from umap import plot as umap_plot

    umap_plot.points(mapper)
    umap_plot.points(mapper, labels=iris.target)
    umap_plot.points(mapper, values=iris.data[:, 0])
    umap_plot.points(mapper, labels=iris.target, subset_points=iris_selection)
    umap_plot.points(mapper, values=iris.data[:, 0], subset_points=iris_selection)
    umap_plot.points(mapper, theme="fire")
    umap_plot.diagnostic(mapper, diagnostic_type="all")
    umap_plot.diagnostic(mapper, diagnostic_type="neighborhood")
    umap_plot.connectivity(mapper)
    umap_plot.connectivity(mapper, theme="fire")
    umap_plot.connectivity(mapper, edge_bundling="hammer")
    umap_plot.interactive(mapper)
    umap_plot.interactive(mapper, labels=iris.target)
    umap_plot.interactive(mapper, values=iris.data[:, 0])
    umap_plot.interactive(mapper, labels=iris.target, subset_points=iris_selection)
    umap_plot.interactive(mapper, values=iris.data[:, 0], subset_points=iris_selection)
    umap_plot.interactive(mapper, theme="fire")
    umap_plot._datashade_points(mapper.embedding_)
    umap_plot._datashade_points(mapper.embedding_, labels=iris.target)
    umap_plot._datashade_points(mapper.embedding_, values=iris.data[:, 0])