Metadata-Version: 2.4
Name: dag-modelling
Version: 0.16.0
Summary: A python implementation of the vectorized direct acyclic graph programming with lazy evaluation
Author-email: DAGModelling Team <dagflow@jinr.ru>
Maintainer-email: DAGModelling Team <dagflow@jinr.ru>
License-Expression: MIT
Project-URL: Bug Tracker, https://github.com/dagflow-team/dag-modelling/issues
Project-URL: DAGModelling Team, https://github.com/dagflow-team
Project-URL: documentation, https://github.com/dagflow-team/dag-modelling/wiki
Project-URL: homepage, https://github.com/dagflow-team/dag-modelling
Project-URL: repository, https://github.com/dagflow-team/dag-modelling
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: contextlib2
Requires-Dist: h5py
Requires-Dist: latexdatax
Requires-Dist: matplotlib
Requires-Dist: nested-mapping>=0.11
Requires-Dist: numba
Requires-Dist: numpy
Requires-Dist: ordered-set
Requires-Dist: pandas
Requires-Dist: plotille
Requires-Dist: pyyaml
Requires-Dist: schema
Requires-Dist: scipy
Requires-Dist: tabulate
Requires-Dist: uproot
Provides-Extra: cython
Requires-Dist: Cython>=3.0; extra == "cython"
Provides-Extra: extra
Requires-Dist: pygraphviz; extra == "extra"
Provides-Extra: test
Requires-Dist: coverage; extra == "test"
Requires-Dist: pygraphviz; extra == "test"
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Provides-Extra: test-cython
Requires-Dist: dayabay-data-official; extra == "test-cython"
Requires-Dist: dgm-dayabay-dev; extra == "test-cython"
Dynamic: license-file

# Summary

[![python](https://img.shields.io/badge/python-3.12-purple.svg)](https://www.python.org/)
[![pipeline](https://git.jinr.ru/dagflow-team/dag-modelling/badges/master/pipeline.svg)](https://git.jinr.ru/dagflow-team/dag-modelling/commits/master)
[![coverage report](https://git.jinr.ru/dagflow-team/dag-modelling/badges/master/coverage.svg)](https://git.jinr.ru/dagflow-team/dag-modelling/-/commits/master)
[![github](https://img.shields.io/badge/github-public-blue?logo=github)](https://github.com/dagflow-team/dag-modelling)
[![gitlab](https://img.shields.io/badge/gitlab-dev-blue?logo=gitlab)](https://git.jinr.ru/dagflow-team/dag-modelling)
[![pypi-release](https://img.shields.io/badge/pypi-release-blue?logo=pypi&logoColor=green)](https://pypi.org/project/dag-modelling)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

The **DAGModelling** software is a python implementation of the dataflow programming with the lazy graph evaluation approach.

Main goals:
*  Lazy evaluated directed acyclic graph;
*  Concise connection syntax;
*  Plotting with graphviz;
*  Flexibility. The goal of DAG-Modelling is not to be efficient, but rather flexible.

The framework is intended to be used for the statistical analysis of the data of *JUNO* and *Daya Bay* neutrino oscillation experiments.

## Installation

### For users (*recommended*)

For regular use, it's best to install [the latest version of the project that's available on PyPi](https://pypi.org/project/dag-modelling/):
```bash
pip install dag-modelling
```

### For developers

We recommend that developers install the package locally in editable mode:
```bash
git clone https://github.com/dagflow-team/dag-modelling.git
cd dag-modelling
pip install -e .
```
This way, the system will track all the changes made to the source files. This means that developers won't need to reinstall the package or set environment variables, even when a branch is changed.

## Cython acceleration (optional)

### Building

Compilation is **opt-in**: `pip install dag-modelling` (and `pip install .`)
gives pure Python. To build the `.so` extensions, install Cython first and
disable build isolation, otherwise the build does not see it:

```bash
pip install cython
pip install --no-build-isolation ".[cython]"                              # from a checkout
pip install --no-build-isolation --no-binary dag-modelling dag-modelling  # from PyPI
```

The `cython` extra alone does **not** compile anything. From PyPI,
`--no-binary` is needed too, since the published wheel is pure Python.

When editing `.pyx` sources, rebuild in place:

```bash
python setup.py build_ext --inplace
```

### Three files per compiled class

| File | Role |
|---|---|
| `x.pxd` | C-level field/signature declarations, for `cimport` |
| `x.pyx` | `cdef class`, hot path only (`cpdef`/`cdef`) |
| `x.py`  | pure-Python fallback, same interface |
| `x_methods.py` | shared cold-path mixin `_XMethods` (`__slots__ = ()`) |

At import time Python prefers the compiled `x.<abi>.so` over `x.py`, so
`from dag_modelling.core.node import Node` works either way.

### Switching to pure Python

Set `DGM_DISABLE_CYTHON=1` to use the `.py` core even when `.so` files
are built, e.g. to run tests in both modes:

```bash
pytest                         # compiled core (if built)
DGM_DISABLE_CYTHON=1 pytest    # pure-Python core
```

The variable is read on the first `import dag_modelling`, so a running process
cannot switch. To check which core is loaded, look at
`dag_modelling.core.node_eval.__file__` (`.so` or `.py`).

## Example

For example, let's consider a sum of three input nodes and then a product of the result with another array.

```python
from numpy import arange

from dag_modelling.core.graph import Graph
from dag_modelling.plot.graphviz import savegraph
from dag_modelling.lib.common import Array
from dag_modelling.lib.arithmetic import Sum, Product

# Define a source data
array = arange(3, dtype="d")

# Check predefined Array, Sum and Product
with Graph(debug=debug) as graph:
    # Define nodes
    (in1, in2, in3, in4) = (Array(name, array) for name in ("n1", "n2", "n3", "n4"))
    s = Sum("sum")
    m = Product("product")

    # Connect nodes
    (in1, in2, in3) >> s
    (in4, s) >> m
    graph.close()

    print("Result:", m.outputs["result"].data) # must print [0. 3. 12.]
    savegraph(graph, "dag_modelling_example_1a.png")
```
The printed result must be `[0. 3. 12.]`, and the created image looks as

![graph example](example/dag_modelling_example_1a.png)


For more examples see [example/example.py](example/example.py) or [tests](tests).

Please, note, that examples are using `pygraphviz` package, which is optional and not requested by default.

## Additional modules

Supplementary python modules:
* [dgm-reactor-neutrino](https://github.com/dagflow-team/dgm-reactor-neutrino) — nodes related to reactor neutrino oscillations.
* [dgm-fit](https://github.com/dagflow-team/dgm-fit) — fitter interface.
* [Daya Bay model](https://github.com/dagflow-team/dgm-dayabay-dev) — implementation of the Daya Bay oscillation analysis, development version.

