spams-cython
This package exposes convenient interfaces of some functions of the SPArse Modeling Software (SPAMS) C++ library, allowing them to be used from Cython code by releasing the Python Global Interpreter Lock (GIL)
Installation from PyPI
pip install spams-cython
Installation from source
git clone https://github.com/getspams/spams-cython.git
cd spams-cython
pip install .
Use spams-cython into your project
pyproject.toml
[build-system]
requires = [
"setuptools",
"Cython",
"spams-cython"
]
setup.py
from setuptools import setup, Extension
from Cython.Build import cythonize
import cyspams
extensions = [
Extension(
mymodule,
sources['mymodule.pyx'],
include_dirs=cyspams.get_include()
)
]
setup(ext_modules=cythonize(extensions))
mymodule.pyx
from cyspams.interfaces cimport nnls, lasso
Note
To build your project with
spams-cythonyou need to have a BLAS/LAPACK library on your system (e.g. OpenBLAS, Intel MKL)
Exposed functions
nnls
void nnls(const double *A, const double *y, const int m, const int n, double *x, double &rnorm)
Args in:
A → Matrix 'A = (m, n)' stored as 1D contiguous array (column-major order)
y → Vector 'y = (m)'
m → Dimension 'm'
n → Dimension 'n'
Args out:
x → Solution vector 'x = (n)'
rnorm → Squared Euclidean norm of the final residual vector
lasso
void lasso(double *A, double *y, const int m, const int p, const int n, double *x)
void lasso(double *A, double *y, const int m, const int p, const int n, double *x, const double lambda1, const double lambda2)
void lasso(double *A, double *y, const int m, const int p, const int n, double *x, const double lambda1, const double lambda2, const int mode, const bint pos)
void lasso(double *A, double *y, const int m, const int p, const int n, double *x, const double lambda1, const double lambda2, const int mode, const bint pos, const bint ols, const int max_length_path, const int L, const bint cholesky, const int n_threads, const bint verbose)
Args in:
A → Matrix 'A = (m, p)' stored as 1D contiguous array (column-major order)
y → Matrix 'y = (m, n)' stored as 1D contiguous array (column-major order)
m → Dimension 'm'
p → Dimension 'p'
n → Dimension 'n'
lambda1 → Regularization parameter (default = 0.0)
lambda2 → Parameter for solving the Elastic-Net (default = 0.0)
mode → 0 = L1COEFFS, 1 = L2ERROR, 2 = PENALTY, 3 = SPARSITY, 4 = L2ERROR2, 5 = PENALTY2, 6 = FISTAMODE (default = 2)
pos → Adds non-negativity constraints on the coefficients (default = true)
ols → Perform an orthogonal projection before returning the solution (default = false)
max_length_path → Maximum length of the path (default = -1)
L → Maximum number of steps of the homotopy algorithm. Can be used as a stopping criterion (default = -1)
cholesky → Choose between Cholesky implementation or one based on the matrix inversion Lemma (default = false)
n_threads → Number of threads to use (default = 1)
verbose → Verbose mode (default = false)
Args out:
x → Solution matrix 'x = (p, n)' stored as 1D contiguous array (column-major order)
Metadata
Release files for spams-cython 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spams-cython-1.0.0.tar.gz | 148.7 kB | Without provenance | Details for spams-cython-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spams_cython-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for spams_cython-1.0.0-py3-none-any.whl |
Total release size: 305.8 kB
Release files / spams-cython-1.0.0.tar.gz
| Download URL | spams-cython-1.0.0.tar.gz |
|---|---|
| Size | 148.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7a1e32bde4e0a7d6fd61fc3922f7349d66a44b5cf2a8ab6ec14167150daa0ad
|
|
BLAKE2b-256 checksum How to use checksums |
9eaf411eeb198acf294a977436dee8cf546e071146719b212be665618a209c92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.9
|
Release files / spams_cython-1.0.0-py3-none-any.whl
| Download URL | spams_cython-1.0.0-py3-none-any.whl |
|---|---|
| Size | 157.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b77446cf42556613a847197d5d4cb0d2ee4c44eb99ce209cc19a421e1e776be6
|
|
BLAKE2b-256 checksum How to use checksums |
6f3ea1a9eb08de9ca17a96f5edb2c22225872f7a4cf644c4b95a7a0fe99c9f10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.9
|
Security for spams-cython 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.