diff options
author | Alexandre Gramfort <alexandre.gramfort@m4x.org> | 2017-07-12 23:56:27 +0200 |
---|---|---|
committer | Alexandre Gramfort <alexandre.gramfort@m4x.org> | 2017-07-20 14:08:02 +0200 |
commit | 95db977e8b931277af5dadbd79eccbd5fbb8bb62 (patch) | |
tree | 4b48e558afceddfcb640e42bb0682bdcccb02b55 /test | |
parent | 37ca3142a4c8c808382f5eb1c23bf198c3e4610e (diff) |
pep8
Diffstat (limited to 'test')
-rw-r--r-- | test/test_emd_multi.py | 27 | ||||
-rw-r--r-- | test/test_gpu_sinkhorn.py | 6 | ||||
-rw-r--r-- | test/test_load_module.py | 4 |
3 files changed, 19 insertions, 18 deletions
diff --git a/test/test_emd_multi.py b/test/test_emd_multi.py index ee0a20e..99173e9 100644 --- a/test/test_emd_multi.py +++ b/test/test_emd_multi.py @@ -7,31 +7,30 @@ Created on Fri Mar 10 09:56:06 2017 """ import numpy as np -import pylab as pl -import ot +import ot from ot.datasets import get_1D_gauss as gauss -reload(ot.lp) +# reload(ot.lp) #%% parameters -n=5000 # nb bins +n = 5000 # nb bins # bin positions -x=np.arange(n,dtype=np.float64) +x = np.arange(n, dtype=np.float64) # Gaussian distributions -a=gauss(n,m=20,s=5) # m= mean, s= std +a = gauss(n, m=20, s=5) # m= mean, s= std -ls= range(20,1000,10) -nb=len(ls) -b=np.zeros((n,nb)) +ls = range(20, 1000, 10) +nb = len(ls) +b = np.zeros((n, nb)) for i in range(nb): - b[:,i]=gauss(n,m=ls[i],s=10) + b[:, i] = gauss(n, m=ls[i], s=10) # loss matrix -M=ot.dist(x.reshape((n,1)),x.reshape((n,1))) -#M/=M.max() +M = ot.dist(x.reshape((n, 1)), x.reshape((n, 1))) +# M/=M.max() #%% @@ -39,10 +38,10 @@ print('Computing {} EMD '.format(nb)) # emd loss 1 proc ot.tic() -emd_loss4=ot.emd2(a,b,M,1) +emd_loss4 = ot.emd2(a, b, M, 1) ot.toc('1 proc : {} s') # emd loss multipro proc ot.tic() -emd_loss4=ot.emd2(a,b,M) +emd_loss4 = ot.emd2(a, b, M) ot.toc('multi proc : {} s') diff --git a/test/test_gpu_sinkhorn.py b/test/test_gpu_sinkhorn.py index bfa2cd2..841f062 100644 --- a/test/test_gpu_sinkhorn.py +++ b/test/test_gpu_sinkhorn.py @@ -3,8 +3,10 @@ import numpy as np import time import ot.gpu + def describeRes(r): - print("min:{:.3E}, max::{:.3E}, mean::{:.3E}, std::{:.3E}".format(np.min(r),np.max(r),np.mean(r),np.std(r))) + print("min:{:.3E}, max::{:.3E}, mean::{:.3E}, std::{:.3E}".format( + np.min(r), np.max(r), np.mean(r), np.std(r))) for n in [5000, 10000, 15000, 20000]: @@ -23,4 +25,4 @@ for n in [5000, 10000, 15000, 20000]: print("Normal sinkhorn, time: {:6.2f} sec ".format(time2 - time1)) describeRes(G1) print(" GPU sinkhorn, time: {:6.2f} sec ".format(time3 - time2)) - describeRes(G2)
\ No newline at end of file + describeRes(G2) diff --git a/test/test_load_module.py b/test/test_load_module.py index a04c5df..d77261e 100644 --- a/test/test_load_module.py +++ b/test/test_load_module.py @@ -4,7 +4,7 @@ import ot import doctest # test lp solver -doctest.testmod(ot.lp,verbose=True) +doctest.testmod(ot.lp, verbose=True) # test bregman solver -doctest.testmod(ot.bregman,verbose=True) +doctest.testmod(ot.bregman, verbose=True) |