Parser
Parsers for various probability expression grammars.
- parse_causaleffect(s: str) Expression[source]
Parse a causaleffect probability expression.
- parse_y0(s: str) Expression[source]
Parse a valid Python expression using the
y0.dslobjects, written in a string.- Parameters:
s – The string to parse. Should be a valid Python expression given
from y0.dsl import *. Variables of the form A-Z, A0-Z0, A_0-Z_0, A1-Z1, A_1-Z_1, …, A9-Z9, A_9-Z_9 are available.- Returns:
An expression object.
>>> from y0.parser import parse_y0 >>> from y0.dsl import P, PP, A, B, Sum, Pi1 >>> parse_y0("Sum[B](P(A|B) * P(B))") == Sum[B](P(A | B) * P(B)) True >>> parse_y0("PP[π1](A)") == PP[Pi1](A) True