Skip to main content

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.constrain([area - PI * radius**2])
@attr.dataclass(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.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

constraintula-0.2.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: constraintula-0.2.1.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.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for constraintula-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7c17e091dbce13dbe7fe83f242310795ba75b07fc56f80b2e6c747f7d9d9ccad
MD5 8a3b1914f180b4f45c4b971bd746438a
BLAKE2b-256 ae90d7e85d9b0eb3698be440566fe38ed65748edf330233f6139f2d648daf7de

See more details on using hashes here.

File details

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

File metadata

  • Download URL: constraintula-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for constraintula-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e117c8821319a6a3c6467bcfe2e8dfc6ea38f0af9fe5bce6d900546109feb638
MD5 95684d2cb430c89fa821b1928d78216c
BLAKE2b-256 6c8fada48e3eb22df3f181f4902c0c15d14a86166cb2b8c4a912f5795adedd0e

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