PyProximal implements proximal operators and proximal algorithms for non-smooth, constrained convex optimization. It deliberately does not implement linear operators: those come from PyLops (pylops.LinearOperator is a hard dependency, >= 2.4.0). Any change that would add a linear-operator implementation here is out of scope by design.
pyproximal/: library code.proximal/: proximal operators (one file per operator family,UpperCaseCamelCasefilename matching the class).projection/: orthogonal projections onto sets, usually wrapped by the indicator-function proximal operators.optimization/: solvers.utils/:moreauandgradtest_proximaltest helpers,BilinearOperator, backend/typing helpers.ProxOperator.py: base class of every proximal operator.
pytests/: pytest suite.docs/,examples/,tutorials/,testdata/: docs, examples, tutorial assets, and test data.pyproject.toml: build, test, lint, and packaging config.Makefile: preferred entry point for local work.
- Prefer
maketargets. Use the*_uvvariants when working in auvenvironment. - Common commands:
make dev-install_uv,make testsormake tests_uv,make lintormake lint_uv,make typeannotormake typeannot_uv,make docupdateormake docupdate_uv. - Packaging uses
hatchling; keep build and version settings inpyproject.toml.
ProxOperatorimplementsproxandproxdualeach in terms of the other via the Moreau decomposition, so a subclass needs only one of them; implement both when closed forms exist.- Decorate every
prox/proxdualwith@_check_tau. gradon the base class is the gradient of the Moreau envelope, not of the function; passhasgrad=Trueand overridegradwhen a true gradient is known.- Solvers exist twice: class-based implementations in
optimization/cls_primal.pyandcls_primaldual.pyhold the logic;primal.pyandprimaldual.pyare thin functional wrappers over them. Change behavior in thecls_*files. - Solvers should support both
numpyandcupyarrays (get_array_module(x0)); numba/CUDA paths are optional and selected through anengineargument with a runtime fallback (seeproximal/Simplex.py).
- Follow the
ruffrules inpyproject.toml; compliance is enforced in CI, as ismypyinstrictmode overpyproximal/. - Keep imports tidy and follow PEP 8 rules.
- Follow
numpydocstyle for docstrings, with aNotessection giving the maths and a reference. - Export new operators in the subpackage
__init__.py: docstring table, star import, and__all__, and list them indocs/source/api/index.rst. - Add or update tests in
pytests/and examples inexamples/and/ortutorials/when changing behavior or public APIs. Validate a new operator withmoreauwhen both prox and dual prox are available, otherwise with ad-hoc edge cases.
- Use
docs/source/contributing.rstas the source of truth for longer contribution workflows, anddocs/source/adding.rst/docs/source/addingsolver.rstwhen implementing a new operator or solver. - If functionality changes, update docs and run the relevant tests before handing off.
- Avoid editing generated artifacts or build output unless the task explicitly requires it.