Define system of constraint equations for initializing data classes
Project description
constraintula
import attr
import constraintula
import numpy as np
PI = np.pi
area, radius = constraintula.symbols('area radius')
@constraintula.constrain([area - PI * radius**2])
@attr.dataclass(frozen=True)
class Circle:
radius: float
area: float
circle_from_radius = Circle(radius=2)
circle_from_area = Circle(area=42)
Installation
User
pip install constraintula
Developer
pip install -e .[dev]
Disclaimer
This is not an officially supported Google product.
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
constraintula-0.3.0.tar.gz
(6.6 kB
view details)
Built Distribution
File details
Details for the file constraintula-0.3.0.tar.gz
.
File metadata
- Download URL: constraintula-0.3.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63df6744a39471f940291cc0d579ac90f8d950317d84378787280023367d81dd |
|
MD5 | af06df669789bae150bc58b626cb709d |
|
BLAKE2b-256 | eb40e8ed3b4465634870c4194557a80497fe5375d1b5a78615c54cf6fc20698b |
File details
Details for the file constraintula-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: constraintula-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9795de6a0ad017d099985e6351bb7da1e95eb206515c53a6507bd52d46fff1a |
|
MD5 | f2561d6f506eccc30a66e539b9ed836f |
|
BLAKE2b-256 | f1fc2a7b839e9193fef5c9abc5666cb97ef7bb89357458cf02c387844a18b1cc |