Skip to content

Commit 5aad08a

Browse files
committed
add test plot
1 parent f204e98 commit 5aad08a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/test_plot.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
3+
import ot
4+
import numpy as np
5+
6+
# import pytest
7+
8+
9+
def test_plot1D_mat():
10+
11+
n = 100 # nb bins
12+
13+
# bin positions
14+
x = np.arange(n, dtype=np.float64)
15+
16+
# Gaussian distributions
17+
a = ot.datasets.get_1D_gauss(n, m=20, s=5) # m= mean, s= std
18+
b = ot.datasets.get_1D_gauss(n, m=60, s=10)
19+
20+
# loss matrix
21+
M = ot.dist(x.reshape((n, 1)), x.reshape((n, 1)))
22+
M /= M.max()
23+
24+
ot.plot.plot1D_mat(a, b, M, 'Cost matrix M')
25+
26+
27+
def test_plot2D_samples_mat():
28+
29+
n = 50 # nb samples
30+
31+
mu_s = np.array([0, 0])
32+
cov_s = np.array([[1, 0], [0, 1]])
33+
34+
mu_t = np.array([4, 4])
35+
cov_t = np.array([[1, -.8], [-.8, 1]])
36+
37+
xs = ot.datasets.get_2D_samples_gauss(n, mu_s, cov_s)
38+
xt = ot.datasets.get_2D_samples_gauss(n, mu_t, cov_t)
39+
40+
G = 1.0 * (np.random.rand(n, n) < 0.01)
41+
42+
ot.plot.plot2D_samples_mat(xs, xt, G, thr=1e-5)

0 commit comments

Comments
 (0)