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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file constraintula-0.3.1.tar.gz.

File metadata

  • Download URL: constraintula-0.3.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for constraintula-0.3.1.tar.gz
Algorithm Hash digest
SHA256 5205b74133628a4299c54862af33e3a0226c8b17fe8f1fc293be5046f356f7a0
MD5 4bdcb0cee3dfbfa194c970560a702d61
BLAKE2b-256 06aa48dbbb1a410b923f03d82405a8d307dd8ca58fd9f23165662473487b90d2

See more details on using hashes here.

File details

Details for the file constraintula-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for constraintula-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa21e7b5ed18c2dbf2cf342eac84f2d03a99d608e6dcf97bc3f3e54a5351dac0
MD5 8b8f7387ef5dc67e51a79a5a9e070974
BLAKE2b-256 2e88a3bf137737db095ec4395c38b520b3faeb1bb1028ea42a75bb6303404877

See more details on using hashes here.

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