Skip to main content

sympy expressions in models

Project description

Modello

This project aims to explore symbolic modeling with object orientated programming. The heavy lifting is done by the sympy library. This module just provides a class to derive models from.

An example based on examples/geometry.py:

from modello import InstanceDummy, Modello
from sympy import sqrt


class RightAngleTriangle(Modello):
    a = InstanceDummy("a", real=True, positive=True)
    b = InstanceDummy("b", real=True, positive=True)
    c = sqrt(a**2 + b**2)


T = RightAngleTriangle("T", a=3, b=4)
assert T.c == 5
T = RightAngleTriangle("T", b=4, c=5)
assert T.a == 3

The best place to see how this can be used is to look in the examples directory, which still needs padding out.

The functionality is covered by tests in both test_modello.py and doctests+tests in the examples.

Installation

This can be installed using one of:

# using pipenv
pipenv install modello

# using pip
pip install --user modello

# using git+pipenv
pipenv install git+https://github.com/Code0x58/modello.git#egg=modello

# using git+pip
pip install --user git+https://github.com/Code0x58/modello.git#egg=modello

Currently this requires Python 3.6+ but the version requirements can drop a couple of minor versions easily if there is interest. Python 2.7 isn't planned to be supported as the Modello class relies on PEP-3115.

Development

Run the tests and linting with python setup.py test. Pushes have the test suite run against them, and will also publish a release if tagged thanks to GitHub Actions. You can reproduce the Actions locally using act, e.g. TWINE_USERNAME= TWINE_PASSWORD= act.

TODO:

  • elaborate on tests/examples
  • think about extending the functionality to allow for a more complete system of constraints, use the RightAngleTriangle example as a base
  • work out patterns for labels/names on symbols so they render nicely
  • for mypy, consider getting value from or removing it
  • implement a first attempt at nested models (named, rather than lists, which would be nice)
  • think about the possibility of symbolic (instance) dummies to allow live updates to system rather than modello instantiation being final

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

modello-0.1.0.post1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

modello-0.1.0.post1-3-none-any.whl (4.5 kB view details)

Uploaded

File details

Details for the file modello-0.1.0.post1.tar.gz.

File metadata

  • Download URL: modello-0.1.0.post1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

File hashes

Hashes for modello-0.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 342753a51d7d02e4e6b581d53c6d6e74fe89a0cbfa709181ccad239f027bc3f9
MD5 e0b0be9e0103080987033ee23ad08983
BLAKE2b-256 74501ae7008ac3864ffcecc8e87ef58c1a2991af2d5e5cc5637e63a644884015

See more details on using hashes here.

File details

Details for the file modello-0.1.0.post1-3-none-any.whl.

File metadata

  • Download URL: modello-0.1.0.post1-3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags:
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

File hashes

Hashes for modello-0.1.0.post1-3-none-any.whl
Algorithm Hash digest
SHA256 63249434bc2d96c33acd886c06ed1c263e464a44143871ef50b36abf89a9c5ce
MD5 632f5f395112187a30b5638b6570a829
BLAKE2b-256 09f4ba3f1b296fe3631e8b1869a0b4a6edc2e82165dae830e9dc5620755a0b53

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