Metadata-Version: 2.1
Name: mona
Version: 0.2.4
Summary: Calculation framework
Home-page: https://github.com/azag0/mona
License: MPL-2.0
Author: Jan Hermann
Author-email: dev@janhermann.cz
Requires-Python: >=3.7,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Utilities
Provides-Extra: cov
Provides-Extra: doc
Provides-Extra: sci
Provides-Extra: test
Requires-Dist: click (>=7.0,<8.0)
Requires-Dist: coverage (>=4.5,<5.0); extra == "cov"
Requires-Dist: graphviz (>=0.10.0,<0.11.0)
Requires-Dist: jinja2 (>=2.10,<3.0); extra == "sci"
Requires-Dist: numpy (>=1.15,<2.0); extra == "sci"
Requires-Dist: pytest (>=3.8,<4.0); extra == "test"
Requires-Dist: pytest-mock (>=1.10,<2.0); extra == "test"
Requires-Dist: sphinx (>=1.8,<2.0); extra == "doc"
Requires-Dist: sphinxcontrib-asyncio (>=0.2.0,<0.3.0); extra == "doc"
Requires-Dist: textx (>=1.5,<1.6); extra == "sci"
Requires-Dist: toml (>=0.9.6,<0.10.0)
Requires-Dist: typing_extensions (>=3.6,<4.0)
Project-URL: Documentation, https://azag0.github.io/mona
Project-URL: Repository, https://github.com/azag0/mona
Description-Content-Type: text/markdown

# Mona

[![build](https://img.shields.io/travis/azag0/mona/master.svg)](https://travis-ci.org/azag0/mona)
[![coverage](https://img.shields.io/codecov/c/github/azag0/mona.svg)](https://codecov.io/gh/azag0/mona)
![python](https://img.shields.io/pypi/pyversions/mona.svg)
[![pypi](https://img.shields.io/pypi/v/mona.svg)](https://pypi.org/project/mona/)
[![commits since](https://img.shields.io/github/commits-since/azag0/mona/latest.svg)](https://github.com/azag0/mona/releases)
[![last commit](https://img.shields.io/github/last-commit/azag0/mona.svg)](https://github.com/azag0/mona/commits/master)
[![license](https://img.shields.io/github/license/azag0/mona.svg)](https://github.com/azag0/mona/blob/master/LICENSE)
[![code style](https://img.shields.io/badge/code%20style-black-202020.svg)](https://github.com/ambv/black)

Mona is a calculation framework that provides [persistent](https://en.wikipedia.org/wiki/Persistence_(computer_science)) [memoization](https://en.wikipedia.org/wiki/Memoization) and turns the Python call stack into a task [dependency graph](https://en.wikipedia.org/wiki/Dependency_graph).

## Installing

Install and update using [Pip](https://pip.pypa.io/en/stable/quickstart/).

```
pip install -U mona
```

## A simple example

```python
from mona import Mona, Rule

app = Mona()

@Rule
async def total(xs):
    return sum(xs)

@app.entry('fib', int)
@Rule
async def fib(n):
    if n <= 2:
        return 1
    return total([fib(n - 1), fib(n - 2)])
```

```
$ export MONA_APP=fib:app
$ mona init
Initializing an empty repository in /home/mona/fib/.mona.
$ mona run fib 5
7c3947: fib(5): will run
0383f6: fib(3): will run
b0287d: fib(4): will run
f47d51: fib(1): will run
9fd61c: fib(2): will run
45c92d: total([fib(2), fib(1)]): will run
2c136c: total([fib(3), fib(2)]): will run
521a8b: total([fib(4), fib(3)]): will run
Finished
$ mona graph
```

<img src="https://raw.githubusercontent.com/azag0/mona/master/docs/fib.svg?sanitize=true" alt width="350">

```python
from fib import app, fib

with app.create_session() as sess:
    assert sess.eval(fib(5)) == sum(sess.eval([fib(4), fib(3)]))
```

## Links

- Documentation: https://azag0.github.io/mona


