A framework to check if Pydantic models are bounded
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bounded_models-0.0.5.tar.gz.
File metadata
- Download URL: bounded_models-0.0.5.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d548faaf8f0cf0710bcb321eb5f53bb814fdc24a6a64dc6fc6a392820d8201c
|
|
| MD5 |
36dd9c43e1d610b88c00e7719a44357a
|
|
| BLAKE2b-256 |
bfd9488c593ea927f01cfdf8ff8724ae17d41abbe0d3a11c6d90cfe4c4907a4c
|
Provenance
The following attestation bundles were made for bounded_models-0.0.5.tar.gz:
Publisher:
release.yaml on shunichironomura/bounded-models
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bounded_models-0.0.5.tar.gz -
Subject digest:
2d548faaf8f0cf0710bcb321eb5f53bb814fdc24a6a64dc6fc6a392820d8201c - Sigstore transparency entry: 839256962
- Sigstore integration time:
-
Permalink:
shunichironomura/bounded-models@100d8d2a0aca010956ac8ffb9c5045052c78b241 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shunichironomura
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@100d8d2a0aca010956ac8ffb9c5045052c78b241 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file bounded_models-0.0.5-py3-none-any.whl.
File metadata
- Download URL: bounded_models-0.0.5-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
219823e57ee9797ebafc301eac218ecd44888914d6f74c9a3e81c77913a1de48
|
|
| MD5 |
4cc9df7e78a25ce2e33e113a0d45c7ef
|
|
| BLAKE2b-256 |
54063358b28569d43fd63374cd492b4372f1c5caa140aab894a245062b92c433
|
Provenance
The following attestation bundles were made for bounded_models-0.0.5-py3-none-any.whl:
Publisher:
release.yaml on shunichironomura/bounded-models
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bounded_models-0.0.5-py3-none-any.whl -
Subject digest:
219823e57ee9797ebafc301eac218ecd44888914d6f74c9a3e81c77913a1de48 - Sigstore transparency entry: 839257012
- Sigstore integration time:
-
Permalink:
shunichironomura/bounded-models@100d8d2a0aca010956ac8ffb9c5045052c78b241 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shunichironomura
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@100d8d2a0aca010956ac8ffb9c5045052c78b241 -
Trigger Event:
workflow_dispatch
-
Statement type: