Skip to content

Define relationships between class attributes via equations of constraint.

License

Notifications You must be signed in to change notification settings

DanielSank/constraintula

Repository files navigation

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.

About

Define relationships between class attributes via equations of constraint.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages