Exemplo n.º 1
0
 def __call__(self, diagram):
     diagram = diagram.downgrade()
     if isinstance(diagram, Bubble):
         obj = Ob(diagram.drawing_name)
         obj.draw_as_box = True
         left, right = Ty(obj), Ty("")
         open_bubble = Box("open_bubble", diagram.dom,
                           left @ diagram.inside.dom @ right)
         close_bubble = Box("_close",
                            left @ diagram.inside.cod @ right,
                            diagram.cod)
         open_bubble.draw_as_wires = True
         close_bubble.draw_as_wires = True
         # Wires can go straight only if types have the same length.
         if len(diagram.dom) == len(diagram.inside.dom):
             open_bubble.bubble_opening = True
         if len(diagram.cod) == len(diagram.inside.cod):
             close_bubble.bubble_closing = True
         return open_bubble\
             >> Id(left) @ self(diagram.inside) @ Id(right)\
             >> close_bubble
     return super().__call__(diagram)
Exemplo n.º 2
0
 def __init__(self, *objects):
     self._objects = tuple(
         x if isinstance(x, Ob) else Ob(x) for x in objects)
     super().__init__(self)