A python interface for hops, the highly optimized polytope sampling toolbox.
Reason this release was yanked:
depcretaed
Project description
HOPSY - Python bindings for HOPS
A python interface for HOPS - the Highly Optimized toolbox for Polytope Sampling.
Built using pybind11
hopsy is the attempt to offer some of the key functionatlity of hops through a Python interface. hops is a highly template-based C++-library for Markov chain Monte Carlo sampling on convex polytopes
P = {x : Ax ≤ b},
which often arises in metabolic flux analysis.
Installation
Install using pip
with
pip install hopsy
or clone this repository and pip install. Note the --recursive
option which is
needed for hops, eigen and pybind11 submodules:
git clone --recursive [url-to-this-repo]
cd hopsy
sudo python3 -m pip install -e .
Alternatively, the project can be built using basic CMake commands:
git clone --recursive [url-to-this-repo]
cd hopsy
mkdir build/ && cd build/
cmake ..
make
In this case, the compiled shared library will be located in build/
and can be used within the directory.
Prerequisites for compiling from source
On Unix (Linux, OS X)
- A compiler with C++11 support
- CMake >= 3.4 or Pip 10+
- Ninja or Pip 10+
- Docker (optional, for building wheels)
License
Examples
A basic usage example is presented below. More examples can be found in tests/
directory.
import hopsy
import numpy as np
# the polytope is defined as
# P := {x : Ax <= b}
# thus we need to define A and b. these constraints form the simple box [0,1]^2.
A = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])
b = np.array([[1], [1], [0], [0]]);
# next we define our target distribution as an isotropic Gaussian with mean 0 and
# identity covariance.
mu = np.zeros((2,1))
cov = np.identity(2)
model = hopsy.MultivariateGaussianModel(mu, cov)
# the complete problem is defined by the target distribution and the constrained domain,
# defined by the above mentioned inequality
problem = hopsy.Problem(A, b, model)
# the run object contains and constructs the markov chains. in the default case, the
# Run object will have a single chain using the Hit-and-Run proposal algorithm and is
# set to produce 10,000 samples.
run = hopsy.Run(problem)
# we finally sample
run.sample()
# from the run, we can now extract the produced data
data = run.data
# the states is a list of lists of numpy.ndarrays, which can be casted to a numpy.ndarray
# which then has the shape (m,n,d), where m is the number of chains, n the number of samples
# and d the dimenion
states = data.states
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file hopsy-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hopsy-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 126cbbf9ca099187c56c8a3932b3a829b4a9775419aa82b5bd40d5244cef1a22 |
|
MD5 | abf911f11dcbe0fca212aa80117e9473 |
|
BLAKE2b-256 | 5d69ba80a47ad140d06f5d5fa64bd80665914343002bf49f4a397febd2ab2b00 |
File details
Details for the file hopsy-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hopsy-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f528895e3456a635467b5f0e1e94ec8d2b11c13c2a6dc592742d4cc12e7acc0 |
|
MD5 | f2576441667b49cc7a46697144f6382a |
|
BLAKE2b-256 | 9cefdc405ed84d1e9101849e025c68a9336f3c22899a1e2fc8c3bfe1a0de94ae |
File details
Details for the file hopsy-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hopsy-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db7e7b930fe7d7caaeb7577ac04531c618d83a5d71f2ad0d238783a07cc3637c |
|
MD5 | 573faca25d75e7191a6ccbb7e63d9810 |
|
BLAKE2b-256 | 9e98a17b12f328a054b92a29f7e4d8abcc13f0f7e32bd759dc22dad76b137f56 |
File details
Details for the file hopsy-0.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hopsy-0.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e531bbf1d36a1c58fc5d2ad9662d96994925d1db58a92d7a76936f56abf39510 |
|
MD5 | 7974a7b164cb71bf72b693fcba64c537 |
|
BLAKE2b-256 | a55209e4afe3b91c12453e5208e4b0d7b0bd4a6ab470fb292250de327c6c8416 |
File details
Details for the file hopsy-0.1.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: hopsy-0.1.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccd2705c48f17e30c01cafa7a6be83fb56a03be848f27fe16800dd16044b15cf |
|
MD5 | 675d0915cead5818245c99737398de57 |
|
BLAKE2b-256 | 1ba7f46cba0da7968b647bd069f9d25f611fb035fee1b140c257373178002172 |