Box#
- class discopy.monoidal.Box(name, dom, cod, **params)[source]#
Bases:
discopy.cat.Box
,Diagram
A box is a diagram with a
name
and the layer of just itself inside.- Parameters:
name (str) – The name of the box.
dom (T) – The domain of the box, i.e. the input.
cod (T) – The codomain of the box, i.e. the output.
data (any) – Extra data in the box, default is
None
.is_dagger (bool, optional) – Whether the box is dagger.
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.symmetric.Swap
.draw_as_braid (bool, optional) – Whether to draw the box as a a braid, e.g.
braided.Braid
.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]