lambeq
lambeq copied to clipboard
Implement ASCII drawing for all lambeq diagrams
Task description
lambeq has a rich interface for drawing diagrams using matplotlib and tikz. it also has an interface for drawing diagrams as ASCII text to a CLI interface. Presently, this text drawing is limited to pregroup diagrams, such as those created by the DisCoCat model.
This task asks for the text drawing feature to be extended to arbitrary diagrams, including the grammar, tensor and quantum diagrams which lambeq provides.
The current implementation assumes that diagrams have a pregroup structure. That is, they consist of a single layer of Word
boxes, followed by layers consisting of swaps, identities or cups. In general, lambeq's backend can represent arbitrary string diagrams which do not have this constraint.
Completing this task requires providing an implementation of diagram2str
in the DiagramTextPrinter
class which can draw arbitrary string diagrams.
Notes
- The text drawing feature is expected to work on all 3 diagram backends provided by lambeq:
- It is necessary to ensure that boxes are wide enough to fit the text content in them.
- Handling of foliation (collapsing boxes into fewer layers when possible) is optional.
References
-
DiagramTextPrinter
class where the implementation should be added. - Implementation of pregroup text drawing
-
Implementation of generic drawing for matplotlib and tikz
- This is for reference only, and the implementation for text drawing can be much simpler. In particular, foliation is not required.
- Examples of various diagrams from lambeq documentation: