Puan DB Python Client
Install
pip install puan-db-python
A quick what-is-dis
A Python library for connecting to a puan-db instance. Puan DB is a logical reasoning database which draws conclusions from a model and finds combinations which satisfies a model while minimizing/maximizing some objective function.
There are two types of variables to keep in mind:
- Primitives. These are defined by an ID given by you, and a lower and upper bound representing which integer values this variable may take in the future. The bound is a complex number so a boolean variable
xwould be declared with the bound0+1j, or just1j, as suchmodel.set_primitive("x", 1j) - Composites. These are created using one or more other primitives or composites as a connecter between them. For instance, an OR-connector is defined as
model.set_or(["x","y","z"]).
Example
import puan_db_python
# Connect to back end
client = puan_db_python.PuanClient(
host="localhost",
port=50051,
ssl=False,
)
# Select or create a model
model = client.create(id="test", password="test")
# Set some primitive variables
model.set_primitives(["x","y","z"])
# And a composite
id = model.set_atleast(["x","y","z"], 1, alias="A")
# Same one could be set instead by
other_id = model.set_or(["x","y","z"], alias="A")
assert id == other_id
# If you forget the id but remember the alias, there's a pointer to it
forgot_id = model.id_from_alias("A")
assert (id == forgot_id) and (forgot_id == other_id)
# Now we can do some propagation to verify some values.
# For instance, if x is 1, then A should be true as well.
# Note that you must give the ID and not the alias when getting its value
model.propagate({"x": 1+1j}).get(id) == 1+1j
# Or maybe we want to find a combination that trying
# to not include x and even more not y, such that (x or y or z) must be true.
# Note that we can send in multiple "objectives" and there's one solution returned
# by each objective
solutions = model.solve(
objectives=[
{
"x": -1,
"y": -2,
}
],
assume={id: 1+1j},
solver=puan_db_python.Solver.GLPK,
)
# Modify the model and compute on it's sub system
# Sub function cuts away the top of the given id's and make them as roots
# This is a stupid example, since it will just leave the graph as is
sub_model = model.sub([id])
# ... do something
sub_model.propagate({"x": 1+1j})
Metadata
Release files for puan-db-python 0.1.41
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 |
|---|---|---|---|---|
| puan_db_python-0.1.41.tar.gz | 13.8 kB | Without provenance | Details for puan_db_python-0.1.41.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| puan_db_python-0.1.41-py3-none-any.whl | Python 3 | none | any | Details for puan_db_python-0.1.41-py3-none-any.whl |
Total release size: 27.5 kB
Release files / puan_db_python-0.1.41.tar.gz
| Download URL | puan_db_python-0.1.41.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2799610eae1464ad676399f3a9e999834226eaa6f13903525c638030009d26cf
|
|
BLAKE2b-256 checksum How to use checksums |
6226072709c7bb60d92138fb37e602d4c85bf3cd94049feabb1b45b3a1a5ab38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.9.19 Darwin/23.1.0
|
Release files / puan_db_python-0.1.41-py3-none-any.whl
| Download URL | puan_db_python-0.1.41-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e70fcea0dc7e1a850f750d892b5f6f270ad8a03b2298e13adc8de0d12e33b88e
|
|
BLAKE2b-256 checksum How to use checksums |
35b2f312fc076d6c0e5c216d156e12708714ed675fed481722abd41026fd458c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.9.19 Darwin/23.1.0
|
Security for puan-db-python 0.1.41
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.