Skip to content

Commit 90e42f3

Browse files
committed
replace function name tin tests
1 parent 507003f commit 90e42f3

File tree

8 files changed

+57
-51
lines changed

8 files changed

+57
-51
lines changed

ot/datasets.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from .utils import check_random_state, deprecated
1313

1414

15-
def get_1D_gauss(n, m, s):
15+
def make_1D_gauss(n, m, s):
1616
"""return a 1D histogram for a gaussian distribution (n bins, mean m and std s)
1717
1818
Parameters
@@ -37,6 +37,12 @@ def get_1D_gauss(n, m, s):
3737
return h / h.sum()
3838

3939

40+
@deprecated()
41+
def get_1D_gauss(n, m, sigma, random_state=None):
42+
""" Deprecated see make_1D_gauss """
43+
return make_1D_gauss(n, m, sigma, random_state=None)
44+
45+
4046
def make_2D_samples_gauss(n, m, sigma, random_state=None):
4147
"""return n samples drawn from 2D gaussian N(m,sigma)
4248

test/test_bregman.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def test_bary():
8383
n_bins = 100 # nb bins
8484

8585
# Gaussian distributions
86-
a1 = ot.datasets.get_1D_gauss(n_bins, m=30, s=10) # m= mean, s= std
87-
a2 = ot.datasets.get_1D_gauss(n_bins, m=40, s=10)
86+
a1 = ot.datasets.make_1D_gauss(n_bins, m=30, s=10) # m= mean, s= std
87+
a2 = ot.datasets.make_1D_gauss(n_bins, m=40, s=10)
8888

8989
# creating matrix A containing all distributions
9090
A = np.vstack((a1, a2)).T
@@ -110,10 +110,10 @@ def test_unmix():
110110
n_bins = 50 # nb bins
111111

112112
# Gaussian distributions
113-
a1 = ot.datasets.get_1D_gauss(n_bins, m=20, s=10) # m= mean, s= std
114-
a2 = ot.datasets.get_1D_gauss(n_bins, m=40, s=10)
113+
a1 = ot.datasets.make_1D_gauss(n_bins, m=20, s=10) # m= mean, s= std
114+
a2 = ot.datasets.make_1D_gauss(n_bins, m=40, s=10)
115115

116-
a = ot.datasets.get_1D_gauss(n_bins, m=30, s=10)
116+
a = ot.datasets.make_1D_gauss(n_bins, m=30, s=10)
117117

118118
# creating matrix A containing all distributions
119119
D = np.vstack((a1, a2)).T

test/test_da.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from numpy.testing.utils import assert_allclose, assert_equal
99

1010
import ot
11-
from ot.datasets import get_data_classif
11+
from ot.datasets import make_data_classif
1212
from ot.utils import unif
1313

1414

@@ -19,8 +19,8 @@ def test_sinkhorn_lpl1_transport_class():
1919
ns = 150
2020
nt = 200
2121

22-
Xs, ys = get_data_classif('3gauss', ns)
23-
Xt, yt = get_data_classif('3gauss2', nt)
22+
Xs, ys = make_data_classif('3gauss', ns)
23+
Xt, yt = make_data_classif('3gauss2', nt)
2424

2525
otda = ot.da.SinkhornLpl1Transport()
2626

@@ -45,7 +45,7 @@ def test_sinkhorn_lpl1_transport_class():
4545
transp_Xs = otda.transform(Xs=Xs)
4646
assert_equal(transp_Xs.shape, Xs.shape)
4747

48-
Xs_new, _ = get_data_classif('3gauss', ns + 1)
48+
Xs_new, _ = make_data_classif('3gauss', ns + 1)
4949
transp_Xs_new = otda.transform(Xs_new)
5050

5151
# check that the oos method is working
@@ -55,7 +55,7 @@ def test_sinkhorn_lpl1_transport_class():
5555
transp_Xt = otda.inverse_transform(Xt=Xt)
5656
assert_equal(transp_Xt.shape, Xt.shape)
5757

58-
Xt_new, _ = get_data_classif('3gauss2', nt + 1)
58+
Xt_new, _ = make_data_classif('3gauss2', nt + 1)
5959
transp_Xt_new = otda.inverse_transform(Xt=Xt_new)
6060

6161
# check that the oos method is working
@@ -92,8 +92,8 @@ def test_sinkhorn_l1l2_transport_class():
9292
ns = 150
9393
nt = 200
9494

95-
Xs, ys = get_data_classif('3gauss', ns)
96-
Xt, yt = get_data_classif('3gauss2', nt)
95+
Xs, ys = make_data_classif('3gauss', ns)
96+
Xt, yt = make_data_classif('3gauss2', nt)
9797

9898
otda = ot.da.SinkhornL1l2Transport()
9999

@@ -119,7 +119,7 @@ def test_sinkhorn_l1l2_transport_class():
119119
transp_Xs = otda.transform(Xs=Xs)
120120
assert_equal(transp_Xs.shape, Xs.shape)
121121

122-
Xs_new, _ = get_data_classif('3gauss', ns + 1)
122+
Xs_new, _ = make_data_classif('3gauss', ns + 1)
123123
transp_Xs_new = otda.transform(Xs_new)
124124

125125
# check that the oos method is working
@@ -129,7 +129,7 @@ def test_sinkhorn_l1l2_transport_class():
129129
transp_Xt = otda.inverse_transform(Xt=Xt)
130130
assert_equal(transp_Xt.shape, Xt.shape)
131131

132-
Xt_new, _ = get_data_classif('3gauss2', nt + 1)
132+
Xt_new, _ = make_data_classif('3gauss2', nt + 1)
133133
transp_Xt_new = otda.inverse_transform(Xt=Xt_new)
134134

135135
# check that the oos method is working
@@ -173,8 +173,8 @@ def test_sinkhorn_transport_class():
173173
ns = 150
174174
nt = 200
175175

176-
Xs, ys = get_data_classif('3gauss', ns)
177-
Xt, yt = get_data_classif('3gauss2', nt)
176+
Xs, ys = make_data_classif('3gauss', ns)
177+
Xt, yt = make_data_classif('3gauss2', nt)
178178

179179
otda = ot.da.SinkhornTransport()
180180

@@ -200,7 +200,7 @@ def test_sinkhorn_transport_class():
200200
transp_Xs = otda.transform(Xs=Xs)
201201
assert_equal(transp_Xs.shape, Xs.shape)
202202

203-
Xs_new, _ = get_data_classif('3gauss', ns + 1)
203+
Xs_new, _ = make_data_classif('3gauss', ns + 1)
204204
transp_Xs_new = otda.transform(Xs_new)
205205

206206
# check that the oos method is working
@@ -210,7 +210,7 @@ def test_sinkhorn_transport_class():
210210
transp_Xt = otda.inverse_transform(Xt=Xt)
211211
assert_equal(transp_Xt.shape, Xt.shape)
212212

213-
Xt_new, _ = get_data_classif('3gauss2', nt + 1)
213+
Xt_new, _ = make_data_classif('3gauss2', nt + 1)
214214
transp_Xt_new = otda.inverse_transform(Xt=Xt_new)
215215

216216
# check that the oos method is working
@@ -252,8 +252,8 @@ def test_emd_transport_class():
252252
ns = 150
253253
nt = 200
254254

255-
Xs, ys = get_data_classif('3gauss', ns)
256-
Xt, yt = get_data_classif('3gauss2', nt)
255+
Xs, ys = make_data_classif('3gauss', ns)
256+
Xt, yt = make_data_classif('3gauss2', nt)
257257

258258
otda = ot.da.EMDTransport()
259259

@@ -278,7 +278,7 @@ def test_emd_transport_class():
278278
transp_Xs = otda.transform(Xs=Xs)
279279
assert_equal(transp_Xs.shape, Xs.shape)
280280

281-
Xs_new, _ = get_data_classif('3gauss', ns + 1)
281+
Xs_new, _ = make_data_classif('3gauss', ns + 1)
282282
transp_Xs_new = otda.transform(Xs_new)
283283

284284
# check that the oos method is working
@@ -288,7 +288,7 @@ def test_emd_transport_class():
288288
transp_Xt = otda.inverse_transform(Xt=Xt)
289289
assert_equal(transp_Xt.shape, Xt.shape)
290290

291-
Xt_new, _ = get_data_classif('3gauss2', nt + 1)
291+
Xt_new, _ = make_data_classif('3gauss2', nt + 1)
292292
transp_Xt_new = otda.inverse_transform(Xt=Xt_new)
293293

294294
# check that the oos method is working
@@ -329,9 +329,9 @@ def test_mapping_transport_class():
329329
ns = 60
330330
nt = 120
331331

332-
Xs, ys = get_data_classif('3gauss', ns)
333-
Xt, yt = get_data_classif('3gauss2', nt)
334-
Xs_new, _ = get_data_classif('3gauss', ns + 1)
332+
Xs, ys = make_data_classif('3gauss', ns)
333+
Xt, yt = make_data_classif('3gauss2', nt)
334+
Xs_new, _ = make_data_classif('3gauss', ns + 1)
335335

336336
##########################################################################
337337
# kernel == linear mapping tests
@@ -449,8 +449,8 @@ def test_linear_mapping():
449449
ns = 150
450450
nt = 200
451451

452-
Xs, ys = get_data_classif('3gauss', ns)
453-
Xt, yt = get_data_classif('3gauss2', nt)
452+
Xs, ys = make_data_classif('3gauss', ns)
453+
Xt, yt = make_data_classif('3gauss2', nt)
454454

455455
A, b = ot.da.OT_mapping_linear(Xs, Xt)
456456

@@ -467,8 +467,8 @@ def test_linear_mapping_class():
467467
ns = 150
468468
nt = 200
469469

470-
Xs, ys = get_data_classif('3gauss', ns)
471-
Xt, yt = get_data_classif('3gauss2', nt)
470+
Xs, ys = make_data_classif('3gauss', ns)
471+
Xt, yt = make_data_classif('3gauss2', nt)
472472

473473
otmap = ot.da.LinearTransport()
474474

@@ -491,8 +491,8 @@ def test_otda():
491491
n_samples = 150 # nb samples
492492
np.random.seed(0)
493493

494-
xs, ys = ot.datasets.get_data_classif('3gauss', n_samples)
495-
xt, yt = ot.datasets.get_data_classif('3gauss2', n_samples)
494+
xs, ys = ot.datasets.make_data_classif('3gauss', n_samples)
495+
xt, yt = ot.datasets.make_data_classif('3gauss2', n_samples)
496496

497497
a, b = ot.unif(n_samples), ot.unif(n_samples)
498498

test/test_dr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_fda():
2222
np.random.seed(0)
2323

2424
# generate gaussian dataset
25-
xs, ys = ot.datasets.get_data_classif('gaussrot', n_samples)
25+
xs, ys = ot.datasets.make_data_classif('gaussrot', n_samples)
2626

2727
n_features_noise = 8
2828

@@ -44,7 +44,7 @@ def test_wda():
4444
np.random.seed(0)
4545

4646
# generate gaussian dataset
47-
xs, ys = ot.datasets.get_data_classif('gaussrot', n_samples)
47+
xs, ys = ot.datasets.make_data_classif('gaussrot', n_samples)
4848

4949
n_features_noise = 8
5050

test/test_gromov.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_gromov():
1515
mu_s = np.array([0, 0])
1616
cov_s = np.array([[1, 0], [0, 1]])
1717

18-
xs = ot.datasets.get_2D_samples_gauss(n_samples, mu_s, cov_s)
18+
xs = ot.datasets.make_2D_samples_gauss(n_samples, mu_s, cov_s)
1919

2020
xt = xs[::-1].copy()
2121

@@ -55,7 +55,7 @@ def test_entropic_gromov():
5555
mu_s = np.array([0, 0])
5656
cov_s = np.array([[1, 0], [0, 1]])
5757

58-
xs = ot.datasets.get_2D_samples_gauss(n_samples, mu_s, cov_s)
58+
xs = ot.datasets.make_2D_samples_gauss(n_samples, mu_s, cov_s)
5959

6060
xt = xs[::-1].copy()
6161

@@ -96,8 +96,8 @@ def test_gromov_barycenter():
9696
ns = 50
9797
nt = 60
9898

99-
Xs, ys = ot.datasets.get_data_classif('3gauss', ns)
100-
Xt, yt = ot.datasets.get_data_classif('3gauss2', nt)
99+
Xs, ys = ot.datasets.make_data_classif('3gauss', ns)
100+
Xt, yt = ot.datasets.make_data_classif('3gauss2', nt)
101101

102102
C1 = ot.dist(Xs)
103103
C2 = ot.dist(Xt)
@@ -123,8 +123,8 @@ def test_gromov_entropic_barycenter():
123123
ns = 50
124124
nt = 60
125125

126-
Xs, ys = ot.datasets.get_data_classif('3gauss', ns)
127-
Xt, yt = ot.datasets.get_data_classif('3gauss2', nt)
126+
Xs, ys = ot.datasets.make_data_classif('3gauss', ns)
127+
Xt, yt = ot.datasets.make_data_classif('3gauss2', nt)
128128

129129
C1 = ot.dist(Xs)
130130
C2 = ot.dist(Xt)
@@ -133,13 +133,13 @@ def test_gromov_entropic_barycenter():
133133
Cb = ot.gromov.entropic_gromov_barycenters(n_samples, [C1, C2],
134134
[ot.unif(ns), ot.unif(nt)
135135
], ot.unif(n_samples), [.5, .5],
136-
'square_loss', 1e-3,
136+
'square_loss', 2e-3,
137137
max_iter=100, tol=1e-3)
138138
np.testing.assert_allclose(Cb.shape, (n_samples, n_samples))
139139

140140
Cb2 = ot.gromov.entropic_gromov_barycenters(n_samples, [C1, C2],
141141
[ot.unif(ns), ot.unif(nt)
142142
], ot.unif(n_samples), [.5, .5],
143-
'kl_loss', 1e-3,
143+
'kl_loss', 2e-3,
144144
max_iter=100, tol=1e-3)
145145
np.testing.assert_allclose(Cb2.shape, (n_samples, n_samples))

test/test_optim.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def test_conditional_gradient():
1616
x = np.arange(n_bins, dtype=np.float64)
1717

1818
# Gaussian distributions
19-
a = ot.datasets.get_1D_gauss(n_bins, m=20, s=5) # m= mean, s= std
20-
b = ot.datasets.get_1D_gauss(n_bins, m=60, s=10)
19+
a = ot.datasets.make_1D_gauss(n_bins, m=20, s=5) # m= mean, s= std
20+
b = ot.datasets.make_1D_gauss(n_bins, m=60, s=10)
2121

2222
# loss matrix
2323
M = ot.dist(x.reshape((n_bins, 1)), x.reshape((n_bins, 1)))
@@ -45,8 +45,8 @@ def test_generalized_conditional_gradient():
4545
x = np.arange(n_bins, dtype=np.float64)
4646

4747
# Gaussian distributions
48-
a = ot.datasets.get_1D_gauss(n_bins, m=20, s=5) # m= mean, s= std
49-
b = ot.datasets.get_1D_gauss(n_bins, m=60, s=10)
48+
a = ot.datasets.make_1D_gauss(n_bins, m=20, s=5) # m= mean, s= std
49+
b = ot.datasets.make_1D_gauss(n_bins, m=60, s=10)
5050

5151
# loss matrix
5252
M = ot.dist(x.reshape((n_bins, 1)), x.reshape((n_bins, 1)))

test/test_ot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010

1111
import ot
12-
from ot.datasets import get_1D_gauss as gauss
12+
from ot.datasets import make_1D_gauss as gauss
1313
import pytest
1414

1515

test/test_plot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def test_plot1D_mat():
2020
x = np.arange(n_bins, dtype=np.float64)
2121

2222
# Gaussian distributions
23-
a = ot.datasets.get_1D_gauss(n_bins, m=20, s=5) # m= mean, s= std
24-
b = ot.datasets.get_1D_gauss(n_bins, m=60, s=10)
23+
a = ot.datasets.make_1D_gauss(n_bins, m=20, s=5) # m= mean, s= std
24+
b = ot.datasets.make_1D_gauss(n_bins, m=60, s=10)
2525

2626
# loss matrix
2727
M = ot.dist(x.reshape((n_bins, 1)), x.reshape((n_bins, 1)))
@@ -43,8 +43,8 @@ def test_plot2D_samples_mat():
4343
mu_t = np.array([4, 4])
4444
cov_t = np.array([[1, -.8], [-.8, 1]])
4545

46-
xs = ot.datasets.get_2D_samples_gauss(n_bins, mu_s, cov_s)
47-
xt = ot.datasets.get_2D_samples_gauss(n_bins, mu_t, cov_t)
46+
xs = ot.datasets.make_2D_samples_gauss(n_bins, mu_s, cov_s)
47+
xt = ot.datasets.make_2D_samples_gauss(n_bins, mu_t, cov_t)
4848

4949
G = 1.0 * (np.random.rand(n_bins, n_bins) < 0.01)
5050

0 commit comments

Comments
 (0)