Esempio n. 1
0
def test_simulate_models_nontrivial():
    # XXX test descent into ExpLit
    # XXX test descent into ExpNumpar
    # XXX test descent into ExpNampar
    # XXX test descent into ExpCol
    # XXX test descent into ExpSub
    # XXX test descent into ExpCollate
    # XXX test descent into ExpIn
    # XXX test descent into ExpCast
    # XXX test descent into ExpExists
    # XXX test descent into ExpApp
    # XXX test descent into ExpAppStar
    # XXX test descent into ExpCase
    mutinf0 = ast.ExpBQLMutInf(['c0'], ['c1', 'c2'],
                               [('c3', ast.ExpLit(ast.LitInt(3)))], None)
    mutinf1 = ast.ExpBQLMutInf(['c4', 'c5'], ['c6'],
                               [('c7', ast.ExpLit(ast.LitString('ergodic')))],
                               100)
    probdensity = ast.ExpBQLProbDensity(
        [('x', ast.ExpLit(ast.LitFloat(1.2)))],
        # No conditions for now -- that changes the weighting of the average.
        [])
    expression0 = ast.ExpOp(ast.OP_LT, [
        mutinf0,
        ast.ExpOp(ast.OP_MUL, [ast.ExpLit(ast.LitFloat(0.1)), mutinf1]),
    ])
    expression1 = probdensity
    simmodels = ast.SimulateModelsExp([
        ast.SelColExp(expression0, 'quagga'),
        ast.SelColExp(expression1, 'eland'),
    ], 'p', 'g')
    assert macro.expand_simulate_models(simmodels) == \
        ast.Select(ast.SELQUANT_ALL,
            [
                ast.SelColExp(
                    ast.ExpOp(ast.OP_LT, [
                        ast.ExpCol(None, 'v0'),
                        ast.ExpOp(ast.OP_MUL, [
                            ast.ExpLit(ast.LitFloat(0.1)),
                            ast.ExpCol(None, 'v1'),
                        ])
                    ]),
                    'quagga'),
                ast.SelColExp(ast.ExpCol(None, 'v2'), 'eland'),
            ],
            [ast.SelTab(
                ast.SimulateModels(
                    [
                        ast.SelColExp(mutinf0, 'v0'),
                        ast.SelColExp(mutinf1, 'v1'),
                        ast.SelColExp(probdensity, 'v2'),
                    ], 'p', 'g'),
                None)],
            None, None, None, None)
Esempio n. 2
0
 def p_bqlfn_condjprob_const(self, targets, constraints):
     return ast.ExpBQLProbDensity(targets, constraints)
Esempio n. 3
0
 def p_bqlfn_condprob_const(self, col, e, constraints):
     return ast.ExpBQLProbDensity([(col, e)], constraints)
Esempio n. 4
0
 def p_bqlfn_jprob_const(self, targets):
     return ast.ExpBQLProbDensity(targets, [])
Esempio n. 5
0
 def p_bqlfn_prob_const(self, col, e):
     return ast.ExpBQLProbDensity([(col, e)], [])