Bounded Models
[!WARNING] This project is in early development. The API may change significantly.
A framework to check if Pydantic models are "bounded" and enable uniform sampling from constrained spaces.
Installation
pip install bounded-models
# or
uv add bounded-models
Quick Start
from typing import Literal
from bounded_models import FieldHandlerRegistry
from pydantic import BaseModel, Field
class Config(BaseModel):
mode: Literal["fast", "slow"]
threshold: float = Field(ge=0.0, le=1.0)
count: int = Field(ge=1, le=10)
registry = FieldHandlerRegistry.default()
registry.check_model_boundedness(Config) # True
registry.model_dimensions(Config) # 3
# Sample from unit hypercube [0, 1]^dim
registry.sample_model([0.5, 0.5, 0.5], Config)
# Config(mode='slow', threshold=0.5, count=5)
Supported Field Types
| Type | Example |
|---|---|
Numeric (int, float) |
Field(ge=0, le=10) |
Literal |
Literal["a", "b", "c"] |
Enum |
class Color(Enum): ... |
Nested BaseModel |
BoundedModel subclasses |
Documentation
For detailed usage, see the documentation.
License
MIT
Metadata
Release files for bounded-models 0.0.5
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 | |
|---|---|---|---|---|
| bounded_models-0.0.5.tar.gz | 10.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bounded_models-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.4 kB
Release files / bounded_models-0.0.5.tar.gz
| Download URL | bounded_models-0.0.5.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d548faaf8f0cf0710bcb321eb5f53bb814fdc24a6a64dc6fc6a392820d8201c
|
|
BLAKE2b-256 checksum How to use checksums |
bfd9488c593ea927f01cfdf8ff8724ae17d41abbe0d3a11c6d90cfe4c4907a4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Jan 20, 2026.
Transparency logRelease files / bounded_models-0.0.5-py3-none-any.whl
| Download URL | bounded_models-0.0.5-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
219823e57ee9797ebafc301eac218ecd44888914d6f74c9a3e81c77913a1de48
|
|
BLAKE2b-256 checksum How to use checksums |
54063358b28569d43fd63374cd492b4372f1c5caa140aab894a245062b92c433
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Jan 20, 2026.
Transparency logSecurity for bounded-models 0.0.5
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 2 files in this release have been uploaded with provenance metadata.
Attestation for bounded_models-0.0.5.tar.gz
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 Jan 20, 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.