diff options
author | Rémi Flamary <remi.flamary@gmail.com> | 2018-05-11 17:01:23 +0200 |
---|---|---|
committer | Rémi Flamary <remi.flamary@gmail.com> | 2018-05-11 17:01:23 +0200 |
commit | 4285cf64f8a2ec481586a190dd545d2a8946e134 (patch) | |
tree | eb21bc679a248927f78f852afb5df13b62288405 /ot/lp/cvx.py | |
parent | 3aee908ad42d65897f1916de6eab84921ac94a10 (diff) |
remove unused sparse
Diffstat (limited to 'ot/lp/cvx.py')
-rw-r--r-- | ot/lp/cvx.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ot/lp/cvx.py b/ot/lp/cvx.py index 93097d1..193c0f5 100644 --- a/ot/lp/cvx.py +++ b/ot/lp/cvx.py @@ -13,7 +13,7 @@ import scipy.sparse as sps try: import cvxopt - from cvxopt import solvers, matrix, sparse, spmatrix + from cvxopt import solvers, matrix, spmatrix except ImportError: cvxopt = False @@ -114,13 +114,15 @@ def barycenter(A, M, weights=None, verbose=False, log=False, solver='interior-po A_eq = sps.vstack((A_eq1, A_eq2)) b_eq = np.concatenate((b_eq1, b_eq2)) - if not cvxopt or solver in ['interior-point']: # cvxopt not installed or simplex/interior point + if not cvxopt or solver in ['interior-point']: + # cvxopt not installed or interior point if solver is None: solver = 'interior-point' options = {'sparse': True, 'disp': verbose} - sol = sp.optimize.linprog(c, A_eq=A_eq, b_eq=b_eq, method=solver, options=options) + sol = sp.optimize.linprog(c, A_eq=A_eq, b_eq=b_eq, method=solver, + options=options) x = sol.x b = x[-n:] @@ -129,7 +131,9 @@ def barycenter(A, M, weights=None, verbose=False, log=False, solver='interior-po h = np.zeros((n_distributions * n2 + n)) G = -sps.eye(n_distributions * n2 + n) - sol = solvers.lp(matrix(c), scipy_sparse_to_spmatrix(G), matrix(h), A=scipy_sparse_to_spmatrix(A_eq), b=matrix(b_eq), solver=solver) + sol = solvers.lp(matrix(c), scipy_sparse_to_spmatrix(G), matrix(h), + A=scipy_sparse_to_spmatrix(A_eq), b=matrix(b_eq), + solver=solver) x = np.array(sol['x']) b = x[-n:].ravel() |