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.contrain([area - PI * radius**2])
@attr.attrs(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.2.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file constraintula-0.2.tar.gz
.
File metadata
- Download URL: constraintula-0.2.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cf593e581ac7146dba9f132e38878adca1980351b3de7e9c2cbda55006a1124 |
|
MD5 | ae316dd33a8e56a00714e83c1f570449 |
|
BLAKE2b-256 | 3fc9fc84546971d4d24176b5e408c0cb42c9e3b7b62f2d66317ad49a693a1c2c |
File details
Details for the file constraintula-0.2-py3-none-any.whl
.
File metadata
- Download URL: constraintula-0.2-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbe3f0211ccc173f303c292e3b97778863fb1145d21fe1d12e68da0953c84c48 |
|
MD5 | 59dec4e559c6439ebe80bacef995379a |
|
BLAKE2b-256 | 4d9f31bb23b56310fd0a83137501de9885c50b545e50133df872b22d51e0cca2 |