rflamary · GitHub

Merged

Merged

Conversation

@rflamary rflamary changed the title Pytest with 85% coverage Pytest with 89% coverage

Jul 24, 2017

agramfort

before_script: # configure a headless display to test plot generation
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start

agramfort


pytest : FORCE
python -m py.test -v test/
python -m py.test -v test/ --cov=ot

agramfort

reg = 1e-3
bary_wass = ot.bregman.barycenter(A, M, reg, weights)

assert np.allclose(1, np.sum(bary_wass))

agramfort

def test_sinkhorn_empty():
# test sinkhorn
n = 100
np.random.seed(0)

agramfort

G, log = ot.sinkhorn([], [], M, 1, stopThr=1e-10, verbose=True, log=True)
# check constratints
assert np.allclose(u, G.sum(1), atol=1e-05) # cf convergence sinkhorn
assert np.allclose(u, G.sum(0), atol=1e-05) # cf convergence sinkhorn

agramfort


# Gaussian distributions
a1 = ot.datasets.get_1D_gauss(n, m=30, s=10) # m= mean, s= std
a2 = ot.datasets.get_1D_gauss(n, m=40, s=10)

agramfort


def test_unmix():

n = 50 # nb bins

agramfort



import ot
import numpy as np

agramfort

# import pytest


def test_OTDA():

agramfort

n = 150 # nb bins

xs, ys = ot.datasets.get_data_classif('3gauss', n)
xt, yt = ot.datasets.get_data_classif('3gauss2', n)

agramfort

import pytest

try: # test if cudamat installed
import ot.dr

agramfort

def test_otda():

n_samples = 150 # nb samples
np.random.seed(0)

agramfort

def test_conditional_gradient():

n_bins = 100 # nb bins
np.random.seed(0)

agramfort

l2 = ot.utils.parmap(f, a)
l2 = list(ot.utils.parmap(f, a))

assert np.allclose(l1, l2)

agramfort


# dist shoul return squared euclidean
assert np.allclose(D, D2)
assert np.allclose(D, D3)

agramfort

M = ot.utils.dist0(n, method='lin_square')

# dist0 default to linear sampling with quadratic loss
assert np.allclose(M[0, -1], (n - 1) * (n - 1))

@rflamary

@rflamary

Labels

None yet

Read the original on github.com ↗