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

Uploaded Source

Built Distribution

constraintula-0.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: constraintula-0.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.23.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for constraintula-0.1.tar.gz
Algorithm Hash digest
SHA256 a53e509225f0f73a0fc0738b90eb61bbe6ca5c30384327a5acc89be16062a609
MD5 290e823ca984a422f78a93eec621d32b
BLAKE2b-256 fd77d3cc5985337ca388a7f77cb2ffc5b091d11770c4601132e5aca7b7c09011

See more details on using hashes here.

File details

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

File metadata

  • Download URL: constraintula-0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for constraintula-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21c950b1380c63eb7f611297c8e770a8bbff5117f69ac03c7f1dd8627b47a52c
MD5 ade1ef286cb3edf20419c64070c65df6
BLAKE2b-256 915154758bbc8ac6f154dd2d86092865d86a89da51e9a1109aa86b398ca28e50

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