Define system of constraint equations for initializing data classes
Project description
constraintula
import attrs
import constraintula
import numpy as np
PI = np.pi
area, radius = constraintula.symbols('area radius')
@constraintula.constrain([area - PI * radius**2])
@attrs.define(frozen=True) # or `@attrs.frozen`
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.1.tar.gz
(10.5 kB
view hashes)
Built Distribution
Close
Hashes for constraintula-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa21e7b5ed18c2dbf2cf342eac84f2d03a99d608e6dcf97bc3f3e54a5351dac0 |
|
MD5 | 8b8f7387ef5dc67e51a79a5a9e070974 |
|
BLAKE2b-256 | 2e88a3bf137737db095ec4395c38b520b3faeb1bb1028ea42a75bb6303404877 |