Box#

class discopy.monoidal.Box(name, dom, cod, **params)[source]#

Bases: Box, Diagram

A box is a diagram with boxes==[self] and offsets==[0].

Parameters:
  • name (any) – Name of the box.

  • dom (discopy.monoidal.Ty) – Domain of the box.

  • cod (discopy.monoidal.Ty) – Codomain of the box.

  • data (any, optional) – Extra data in the box.

  • draw_as_spider (bool, optional) – Whether to draw the box as a spider.

  • draw_as_wires (bool, optional) – Whether to draw the box as wires, e.g. discopy.monoidal.Swap.

  • drawing_name (str, optional) – The name to use when drawing the box.

  • tikzstyle_name (str, optional) – The name of the style when tikzing the box.

  • color (str, optional) – The color to use when drawing the box, one of "white", "red", "green", "blue", "yellow", "black". Default is "red" if draw_as_spider else "white".

  • shape (str, optional) – The shape to use when drawing a spider, one of "circle", "rectangle".

Examples

>>> f = Box('f', Ty('x', 'y'), Ty('z'))
>>> assert Id(Ty('x', 'y')) >> f == f == f >> Id(Ty('z'))
>>> assert Id(Ty()) @ f == f == f @ Id(Ty())
>>> assert f == f[::-1][::-1]
downgrade()[source]#

Downcasting to discopy.monoidal.Box.