.. _`yaml representation`: YAML representation =================== When |symfer| serializes factor expressions from Python memory to a file, it uses the `YAML `_ format. YAML is like `JSON `_, only: - You're allowed to leave out some of the brackets, braces and quotes. - More importantly, you can define *shared* sub-structures within your document by placing an anchor such as ``&f`` at the first occurence, and a link ``*f`` at subsequent occurrences. - An object can be preceded by a ``!tag`` defining its type. The translation is as follows. .. table:: :widths: 1 1 :column-alignment: left left +----------------------------------+----------------------------+ | Python constructor | YAML | +==================================+============================+ |:: |:: | | | | | SumProd(['A','B'],[f,g]) | !sumprod | | | arg: [A,B] | | | fac: [*f,*g] | +----------------------------------+----------------------------+ |:: |:: | | | | | f = Multinom([{'A':[0,1]},..], | &f !multinom | | [0.25,0.75,..]) | dom: [A: [0,0],..] | | | par: [0.25,0.75,..] | +----------------------------------+----------------------------+ |:: |:: | | | | | d = Fun([{'C':[False,True]}], | &d !fun | | [{'A':[0,1],..], | cod: [C: [False,True]] | | [1,0,..]) | dom: [A: [0,1],..] | | | par: [1,0,..] | +----------------------------------+----------------------------+ |:: |:: | | | | | Index([d],[h]) | !index | | | det: [*d] | | | fac: [*h] | +----------------------------------+----------------------------+ |:: |:: | | | | | I() | !i {} | +----------------------------------+----------------------------+ |:: |:: | | | | | Embed([d]) | !embed | | | det: [*d] | +----------------------------------+----------------------------+ |:: |:: | | | | | Reorder([{'newB':'B'}, | !reorder | | {'newA':'A'}], | dic: [newB: B, newA: A] | | [f]) | fac: [*f] | +----------------------------------+----------------------------+