Diagram#
- class discopy.feedback.Diagram(inside, dom, cod, _scan=True)[source]#
Bases:
discopy.markov.Diagram
A feedback diagram is a markov diagram with a
delay()
endofunctor and afeedback()
operator.- Parameters:
inside (monoidal.Layer) – The layers inside the diagram.
dom (Ty) – The domain of the diagram, i.e. its input.
cod (Ty) – The codomain of the diagram, i.e. its output.
Example
>>> x = Ty('x') >>> zero = Box('0', Ty(), x.head) >>> rand = Box('rand', Ty(), x) >>> plus = Box('+', x @ x, x) >>> walk = (rand.delay() @ x.delay() >> zero @ plus.delay() ... >> FollowedBy(x) >> Copy(x)).feedback() >>> walk.draw(path="docs/_static/feedback/feedback-random-walk.png")
- classmethod wait(dom)[source]#
Wait one time step, i.e. Swap(x, x.delay()).feedback().
Example
>>> x = Ty('x') >>> assert Diagram.wait(x) == Swap(x, x.delay()).feedback() >>> Diagram.wait(x).draw(path="docs/_static/feedback/wait.png")
- property time_step: int#
The time step of a diagram is defined only if it is in fact a box.
This is used for checking equality between boxes and diagrams.
Example
>>> f = Box('f', 'x', 'y') >>> assert f.delay(42).time_step == 42
- property d#
delay.
- Type:
Syntactic sugar for meth
- copy_factory#
alias of
Copy
- followed_by#
alias of
FollowedBy
- merge_factory#
alias of
Merge