Ejemplo n.º 1
0
def test_infer_explicit_samples():
    assert parse_bql_string('infer explicit x, predict y with confidence 0.9,'
            ' predict p with confidence 0.8 as q, predict u confidence v,'
            ' predict a as b confidence c,'
            ' predict h confidence k using 42 samples'
            ' from p') == \
        [ast.InferExplicit([
                ast.SelColExp(ast.ExpCol(None, 'x'), None),
                ast.SelColExp(
                    ast.ExpBQLPredict('y', ast.ExpLit(ast.LitFloat(.9)), None),
                    None,
                ),
                ast.SelColExp(
                    ast.ExpBQLPredict('p', ast.ExpLit(ast.LitFloat(.8)), None),
                    'q',
                ),
                ast.PredCol('u', None, 'v', None),
                ast.PredCol('a', 'b', 'c', None),
                ast.PredCol('h', None, 'k', ast.ExpLit(ast.LitInt(42))),
            ],
            'p', None, None, None, None, None)]
Ejemplo n.º 2
0
def test_is_bql():
    assert ast.is_bql(ast.ExpLit(ast.LitInt(0))) == False
    assert ast.is_bql(ast.ExpNumpar(0)) == False
    assert ast.is_bql(ast.ExpNampar(0, 'x')) == False
    assert ast.is_bql(ast.ExpCol('t', 'c')) == False
    # ...
    assert ast.is_bql(ast.ExpBQLPredProb('c'))
    assert ast.is_bql(ast.ExpBQLProb([('c', ast.ExpLit(ast.LitInt(0)))], []))
    assert ast.is_bql(ast.ExpBQLProbFn(ast.ExpLit(ast.LitInt(0)), []))
    assert ast.is_bql(ast.ExpBQLSim(ast.ExpLit(ast.LitInt(0)), []))
    assert ast.is_bql(ast.ExpBQLDepProb('c0', 'c1'))
    assert ast.is_bql(ast.ExpBQLMutInf('c0', 'c1', None, 100))
    assert ast.is_bql(ast.ExpBQLCorrel('c0', 'c1'))
    assert ast.is_bql(ast.ExpBQLPredict('c', ast.ExpLit(ast.LitInt(.5)), None))
    assert ast.is_bql(ast.ExpBQLPredictConf('c', None))
Ejemplo n.º 3
0
 def p_bqlfn_predict(self, col, conf, nsamp):
     return ast.ExpBQLPredict(col, conf, nsamp)