Esempio n. 1
0
 def from_formula(cls, tree_or_string):
     if isinstance(tree_or_string, ParseNode):
         tree = tree_or_string
     else:
         tree = parse(tree_or_string)
     value = Evaluator().eval(tree, require_evalexpr=False)
     assert isinstance(value, cls)
     return value
Esempio n. 2
0
 def from_formula(cls, tree_or_string):
     if isinstance(tree_or_string, ParseNode):
         tree = tree_or_string
     else:
         tree = parse(tree_or_string)
     value = Evaluator().eval(tree, require_evalexpr=False)
     assert isinstance(value, cls)
     return value
Esempio n. 3
0
def test_ModelDesc_from_formula():
    for input in ("y ~ x", parse("y ~ x")):
        md = ModelDesc.from_formula(input)
        assert md.input_code == "y ~ x"
        assert md.lhs_terms == (Term([EvalFactor("y")]),)
        assert md.rhs_terms == (INTERCEPT, Term([EvalFactor("x")]))
Esempio n. 4
0
def test_ModelDesc_from_formula():
    for input in ("y ~ x", parse("y ~ x")):
        md = ModelDesc.from_formula(input)
        assert md.input_code == "y ~ x"
        assert md.lhs_terms == (Term([EvalFactor("y")]),)
        assert md.rhs_terms == (INTERCEPT, Term([EvalFactor("x")]))