def setUp(self):
     self.pset = pg.PrimitiveSet()
     self.pset.add_operator('add', 2)
     self.pset.add_operator('sub', 1)
     self.pset.add_operator('truediv', 3)
     self.pset.add_operator('mul', 1)
     self.pset.add_variable('x')
     self.pset.add_variable('y')
     self.enum = pg.Enumerator(self.pset)
Beispiel #2
0
    def setUp(self):
        self.pset = cy.CyPrimitiveSet()
        self.pset.add_operator('add', 2)
        self.pset.add_operator('sub', 1)
        self.pset.add_operator('truediv', 3)
        self.pset.add_operator('mul', 1)
        self.pset.add_variable('x')
        self.pset.add_variable('y')
        self.enum = cy.CyEnumerator(self.pset)

        # to allow for use of pyGOURGS' compile function
        self.pset_pg = pg.PrimitiveSet()
        self.pset_pg.add_operator('add', 2)
        self.pset_pg.add_operator('sub', 1)
        self.pset_pg.add_operator('truediv', 3)
        self.pset_pg.add_operator('mul', 1)
        self.pset_pg.add_variable('x')
        self.pset_pg.add_variable('y')
        self.enum_pg = pg.Enumerator(self.pset_pg)
Beispiel #3
0
pset.add_operator("operator.and_", 2)
pset.add_operator("operator.or_", 2)
pset.add_operator("operator.not_", 1)
pset.add_operator("if_then_else", 3)
pset.add_variable("A0")
pset.add_variable("A1")
pset.add_variable("A2")
pset.add_variable("D0")
pset.add_variable("D1")
pset.add_variable("D2")
pset.add_variable("D3")
pset.add_variable("D4")
pset.add_variable("D5")
pset.add_variable("D6")
pset.add_variable("D7")
enum = pg.Enumerator(pset)


def compile(expr, pset):
    """
    Compiles the `expr` expression

    Parameters
    ----------

    expr: a string of Python code or any object that when
             converted into string produced a valid Python code
             expression.                 

    pset: Primitive set against which the expression is compiled