pyunigen: bindings to the UniGen almost uniform sampler
This directory provides Python bindings to UniGen on the C++ level, i.e. when importing pyunigen, UniGen becomes part of the Python process itself.
Installing
pip install pyunigen
Pre-built wheels are available for Linux (x86-64, ARM64) and macOS (Apple Silicon).
Compiling
If you don't want to use the pip package, you can build it from a checkout.
It needs GMP and MPFR; CMake builds UniGen's other dependencies from sibling
checkouts next to unigen/, or fetches them from GitHub:
pip install .
Usage
The pyunigen module has one object, Sampler that has two functions
sample and add_clause.
The function add_clause() takes an iterable list of literals such as
[1, 2] which represents the truth 1 or 2 = True. For example,
add_clause([1]) sets variable 1 to True.
The function sample() samples the system of equations that have been added
with add_clause():
>>> from pyunigen import Sampler
>>> c = Sampler()
>>> c.add_clause([1, 5])
>>> c.add_clause([10, 11, 12])
>>> cells, hashes, samples = c.sample(num=2, sampling_set=range(1,5))
>>> print("There are approx. ", cells*2**hashes, " solutions over the sampling set. Samples: ", samples)
There are approx. 16 solutions over the sampling set. Samples: [[1, -2, 3, -4], [1, 2, -3, -4]]
The return value is a tuple of cells and hashes. Which gives how many solutions there are, probabilistically approximately
The samples are over the sampling set, by default all variables. UniGen
simplifies the CNF with Arjun and maps
every sample back to its variables. On an unsatisfiable CNF, sample() returns
(0, 0, []). sample() can only be called once per Sampler.
You can give the following arguments to Sampler:
seed-- sets the random seedverbosity-- sets the verbosity of the system (default = 0)epsilon-- Tolerance parameter of the count, i.e. sets how approximate it is. Default = 0.8delta-- Confidence parameter of the count, i.e. sets how probabilistically correct it is. Default = 0.20kappa-- Uniformity parameter (see the TACAS-15 paper). Default = 0.638multisample-- Return multiple samples from each cell. Default = Falsearjun-- Simplify the CNF with Arjun before sampling. Default = True
Metadata
Release files for pyunigen 2.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 88.5 MB
Release files / pyunigen-2.8.0-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | pyunigen-2.8.0-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
25eeddc7e25928e1f0b3d517ef2cbaee6e9484b9a78f88096ab99da50b9cbe92
|
|
BLAKE2b-256 checksum How to use checksums |
0709729276c1c5a0acfedce8e67aae84d27a39cf72a0692bf41798a556c53fcb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp313-cp313-manylinux_2_34_aarch64.whl
| Download URL | pyunigen-2.8.0-cp313-cp313-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.13 Linux glibc 2.34+ ARM64 |
|
SHA-256 checksum How to use checksums |
fef381fd768656739ba78796755699e7bbfe1c588a973b12007bbd9cdd283ed0
|
|
BLAKE2b-256 checksum How to use checksums |
2a005aed072c00ba8594427a7accb673eb3f7f13880d86ccbe1e657862dbe7a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | pyunigen-2.8.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.9 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ca2b3c6e1e687977cdbe513fa827223c11a7675c2a2bc83d8bbcfeec3d42a3e1
|
|
BLAKE2b-256 checksum How to use checksums |
61cc4e20224feea7bdb91ad00e6041f50642fc885e87dbebe44f4fbedc861f6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | pyunigen-2.8.0-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
29d3353e3b70144785305e84a99df92e7633a869b3548182482b78a99bb2fa0c
|
|
BLAKE2b-256 checksum How to use checksums |
a4ac0560bf1de534981a2c88f21bb032ac65b97262cd7cdf11b30bb8cf7e6681
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp312-cp312-manylinux_2_34_aarch64.whl
| Download URL | pyunigen-2.8.0-cp312-cp312-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.12 Linux glibc 2.34+ ARM64 |
|
SHA-256 checksum How to use checksums |
e3eac55d80e694dca4174a4e5a55775bfae25a32ddd20a47df2776b2b32ea4ab
|
|
BLAKE2b-256 checksum How to use checksums |
0f738072807cdb573d2ff4d9bfe649491c006fa7e82ae1c83e70d8edf687c7d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | pyunigen-2.8.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.9 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
0e0e5b834614519312a64efb38bfd2f49e5d4239684e48866616de0f04d3e481
|
|
BLAKE2b-256 checksum How to use checksums |
3570b0a386c18e43f51d03a842e0974a5a200effc5ade5507009d16e01288ebe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp311-cp311-manylinux_2_34_x86_64.whl
| Download URL | pyunigen-2.8.0-cp311-cp311-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.11 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
c6b39f84453a838ea7be6f46bfaf470163cc414e8d8769c4c9069bc41d6377bc
|
|
BLAKE2b-256 checksum How to use checksums |
cb5380209ec528b29a3b6bb7031eaf3c321de4a14338e274934bcb654b0a3d13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp311-cp311-manylinux_2_34_aarch64.whl
| Download URL | pyunigen-2.8.0-cp311-cp311-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.11 Linux glibc 2.34+ ARM64 |
|
SHA-256 checksum How to use checksums |
2c0f1d0e3cfe15ea74e0f946c219834e90a7b1ccca2c6827b0d6ad9485f02f79
|
|
BLAKE2b-256 checksum How to use checksums |
fa0c6c392628ec9d7d5310ae91f03cbc2d7637d1da5dc708f546ca5f752cc375
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | pyunigen-2.8.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.9 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
eb73ca0d66f4da7c924078fb50d4738ea9659f88032abe12d30f6332be448394
|
|
BLAKE2b-256 checksum How to use checksums |
f206088485f22505bb9d5fd8914897f0bd50a32539b5d38ce0d3486984800098
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp310-cp310-manylinux_2_34_x86_64.whl
| Download URL | pyunigen-2.8.0-cp310-cp310-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
7474f2d265257410701898ff335390e6cc1605b2910e49e2f97cebd815a7a9d2
|
|
BLAKE2b-256 checksum How to use checksums |
3a49c42addf20fde32ad58827d4c5a1c35377480e6f60c0c40f4f232db05539e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp310-cp310-manylinux_2_34_aarch64.whl
| Download URL | pyunigen-2.8.0-cp310-cp310-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.10 Linux glibc 2.34+ ARM64 |
|
SHA-256 checksum How to use checksums |
13abbace20a0af0faf4df6132c9040866f58d8f4a84993a06ba76eed3720910e
|
|
BLAKE2b-256 checksum How to use checksums |
c74eb867e8f2d051b8d2380b3738716380ec376faaff0723c0ce0f7283ff29c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | pyunigen-2.8.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.9 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
09ee331dbc5aabed9703f898d9277d9b49f6fa3ca07afbd55034613e824fd58e
|
|
BLAKE2b-256 checksum How to use checksums |
ece25285af121ff8ae629d9d9de7c3335606eedf911a6c10ed8ca757ce5ec3f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp39-cp39-manylinux_2_34_x86_64.whl
| Download URL | pyunigen-2.8.0-cp39-cp39-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 6.7 MB |
| Tags | CPython 3.9 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
32f2a7578379928daaf2f8df86feb2ce8bca08cff9a71bfe10050d3716620157
|
|
BLAKE2b-256 checksum How to use checksums |
79d18180be94574bbef4b92866e9c43f5782a8edecffab936a8746f55cedc5d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp39-cp39-manylinux_2_34_aarch64.whl
| Download URL | pyunigen-2.8.0-cp39-cp39-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 6.1 MB |
| Tags | CPython 3.9 Linux glibc 2.34+ ARM64 |
|
SHA-256 checksum How to use checksums |
75ae43ccf6d6d2e6342e9db5fec4a0b37154892203ed06fbd6356d4b0e91c3c0
|
|
BLAKE2b-256 checksum How to use checksums |
26390940653eb58467e981321189ab20f6e14e40032d817d3de696bcfc8850e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / pyunigen-2.8.0-cp39-cp39-macosx_11_0_arm64.whl
| Download URL | pyunigen-2.8.0-cp39-cp39-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.9 MB |
| Tags | CPython 3.9 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
6221c3000e947d3dd76cd67de102414254e72a05cca6fb1b20048df7007c6c0d
|
|
BLAKE2b-256 checksum How to use checksums |
90f67b19f9696b55ee42730a88e8ea0b1eacfca16cd24beda642d4773892b2d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for pyunigen 2.8.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.
Full provenance
All 15 files in this release have been uploaded with provenance metadata.
Attestation for pyunigen-2.8.0-cp313-cp313-manylinux_2_34_x86_64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA 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.