Skip to content

Commit

Permalink
pyunlocbox as an optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeff committed Dec 14, 2017
1 parent ba536bd commit d861a7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion pygsp/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
logger = utils.build_logger(__name__)


def _import_pyunlocbox():
try:
from pyunlocbox import functions, solvers
except Exception:
raise ImportError('Cannot import pyunlocbox, which is needed to solve '
'this optimization problem. Try to install it with '
'pip (or conda) install pyunlocbox.')
return functions, solvers


def prox_tv(x, gamma, G, A=None, At=None, nu=1, tol=10e-4, maxit=200, use_matrix=True):
r"""
Total Variation proximal operator for graphs.
Expand Down Expand Up @@ -81,4 +91,5 @@ def l1_a(x):
def l1_at(x):
return G.div(x)

pyunlocbox.prox_l1(x, gamma, A=l1_a, At=l1_at, tight=tight, maxit=maxit, verbose=verbose, tol=tol)
functions, _ = _import_pyunlocbox()
functions.norm_l1(x, gamma, A=l1_a, At=l1_at, tight=tight, maxit=maxit, verbose=verbose, tol=tol)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
# Approximate nearest neighbors for kNN graphs.
'pyflann; python_version == "2.*"',
'pyflann3; python_version == "3.*"',
# Convex optimization on graph.
'pyunlocbox',
# Plot graphs, signals, and filters.
'matplotlib',
# Interactive graph visualization.
Expand All @@ -44,14 +46,12 @@
),
# Testing dependencies.
'test': [
'pyunlocbox',
'flake8',
'coverage',
'coveralls',
],
# Dependencies to build the documentation.
'doc': [
'pyunlocbox',
'sphinx',
'numpydoc',
'sphinxcontrib-bibtex',
Expand Down

0 comments on commit d861a7b

Please sign in to comment.