Skip to main content

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)

Uploaded Source

Built Distribution

constraintula-0.3.1-py3-none-any.whl (11.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page