Metadata-Version: 2.1
Name: discopy
Version: 1.0.0
Summary: The Python toolkit for computing with string diagrams.
Home-page: https://discopy.org
Download-URL: https://github.com/discopy/discopy/archive/1.0.0.tar.gz
Author: Alexis Toumi
Author-email: alexis@toumi.email
Project-URL: Documentation, https://docs.discopy.org
Project-URL: Source, https://github.com/discopy/discopy
Project-URL: Tracker, https://github.com/discopy/discopy/issues
Keywords: diagrams category-theory quantum-computing nlp
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy (>=1.18.1)
Requires-Dist: networkx (>=2.4)
Requires-Dist: matplotlib (>=3.1.2)
Requires-Dist: pillow (>=6.2.1)
Provides-Extra: docs
Requires-Dist: sphinx (==4.5.0) ; extra == 'docs'
Requires-Dist: sphinx-book-theme (==0.3.3) ; extra == 'docs'
Requires-Dist: m2r2 (==0.3.2) ; extra == 'docs'
Requires-Dist: nbsphinx (==0.8.9) ; extra == 'docs'
Requires-Dist: ipykernel (==6.17.0) ; extra == 'docs'
Requires-Dist: sphinxcontrib-youtube (==1.2.0) ; extra == 'docs'
Requires-Dist: jinja2 (==3.0.3) ; extra == 'docs'
Requires-Dist: sphinxcontrib-bibtex ; extra == 'docs'
Requires-Dist: IPython ; extra == 'docs'
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: coverage ; extra == 'test'
Requires-Dist: pycodestyle ; extra == 'test'
Requires-Dist: pytket (==1.1.0) ; extra == 'test'
Requires-Dist: pyzx (>=0.7.0) ; extra == 'test'
Requires-Dist: sympy (==1.9) ; extra == 'test'
Requires-Dist: tensorflow ; extra == 'test'
Requires-Dist: tensornetwork ; extra == 'test'
Requires-Dist: jax ; extra == 'test'
Requires-Dist: jaxlib ; extra == 'test'
Requires-Dist: torch ; extra == 'test'
Requires-Dist: pennylane ; extra == 'test'
Requires-Dist: lxml ; extra == 'test'
Requires-Dist: nltk ; extra == 'test'
Requires-Dist: pylint ; extra == 'test'


![snake equation](https://github.com/discopy/discopy/blob/main/docs/_static/snake-equation.png)

# DisCoPy

[![build](https://github.com/discopy/discopy/actions/workflows/build_test.yml/badge.svg)](https://github.com/discopy/discopy/actions/workflows/build_test.yml)
[![readthedocs](https://readthedocs.org/projects/discopy/badge/?version=main)](https://docs.discopy.org/)
[![PyPI version](https://badge.fury.io/py/discopy.svg)](https://badge.fury.io/py/discopy)
[![DOI: 10.4204/EPTCS.333.13](http://img.shields.io/badge/DOI-10.4204/EPTCS.333.13-brightgreen.svg)](https://doi.org/10.4204/EPTCS.333.13)

DisCoPy is a Python toolkit for computing with [string diagrams](https://en.wikipedia.org/wiki/String_diagram).

* **Organisation:** https://discopy.org
* **Documentation:** https://docs.discopy.org
* **Source code:** https://github.com/discopy/discopy
* **Paper (for applied category theorists):** https://doi.org/10.4204/EPTCS.333.13
* **Paper (for quantum computer scientists):** https://arxiv.org/abs/2205.05190

DisCoPy began as an implementation of [DisCoCat](https://en.wikipedia.org/wiki/DisCoCat) and [QNLP](https://en.wikipedia.org/wiki/Quantum_natural_language_processing). This has now become its own library: [lambeq](https://cqcl.github.io/lambeq).

## Features

* a data structure for arrows in free [dagger categories](https://en.wikipedia.org/wiki/Dagger_category) with formal sums, unary operators and symbolic variables from [SymPy](https://www.sympy.org/en/index.html)
* data structures for string diagrams in any ([pre](https://ncatlab.org/nlab/show/premonoidal+category))[monoidal category](https://en.wikipedia.org/wiki/Monoidal_category) in the [hierarchy of graphical languages](https://en.wikipedia.org/wiki/String_diagram#Hierarchy_of_graphical_languages) (braids, twists, spiders, etc.)
* methods for diagram composition, drawing, rewriting and evaluation as:
  - Python code, i.e. wires as types and boxes as functions
  - [tensor networks](https://en.wikipedia.org/wiki/Tensor_network), i.e. wires as dimensions and boxes as arrays from [NumPy](https://numpy.org), [PyTorch](https://pytorch.org/), [TensorFlow](https://www.tensorflow.org/), [TensorNetwork](https://github.com/google/TensorNetwork) and [JAX](https://github.com/google/jax)
* an implementation of [categorical quantum mechanics](https://en.wikipedia.org/wiki/Categorical_quantum_mechanics) interfacing with:
  - [tket](https://github.com/CQCL/tket) for circuit compilation
  - [PyZX](https://github.com/Quantomatic/pyzx) for optimisation with the [ZX calculus](https://zxcalculus.com/)
  - [PennyLane](https://pennylane.ai/) for automatic differentiation
* an implementation of formal grammars ([context-free](https://en.wikipedia.org/wiki/Context-free_grammar), [categorial](https://en.wikipedia.org/wiki/Categorial_grammar), [pregroup](https://en.wikipedia.org/wiki/Pregroup_grammar) or [dependency](https://en.wikipedia.org/wiki/Dependency_grammar)) with interfaces to [lambeq](https://cqcl.github.io/lambeq), [spaCy](https://spacy.io/) and [NLTK](https://www.nltk.org/)

## Architecture

Software dependencies between modules go top-to-bottom, left-to-right and [forgetful functors](https://en.wikipedia.org/wiki/Forgetful_functor) between categories go the other way.

[![architecture](https://github.com/discopy/discopy/blob/main/docs/api/architecture.png)](https://docs.discopy.org#architecture)

## Quickstart

```shell
pip install discopy
```

If you want to see DisCoPy in action, check out the [QNLP tutorial](https://docs.discopy.org/en/main/notebooks/qnlp.html)!

## Contribute

We're keen to welcome new contributors!

First, read the [contributing guidelines](https://github.com/discopy/discopy/CONTRIBUTING.md).
Then get in touch on [Discord](https://discopy.org/discord)
or [open an issue](https://github.com/discopy/discopy/issues/new).

## How to cite

If you wish to cite DisCoPy in an academic publication, we suggest you cite:

* G. de Felice, A. Toumi & B. Coecke, _DisCoPy: Monoidal Categories in Python_, EPTCS 333, 2021, pp. 183-197, [DOI: 10.4204/EPTCS.333.13](https://doi.org/10.4204/EPTCS.333.13)

If furthermore your work is related to quantum computing, you can also cite:

* A. Toumi, G. de Felice & R. Yeung, _DisCoPy for the quantum computer scientist_, [arXiv:2205.05190](https://arxiv.org/abs/2205.05190)
