from patsy import ModelDesc, Term, EvalFactor
form1 = ModelDesc([Term([EvalFactor("y")])],
[Term([]),
Term([EvalFactor("a")]),
Term([EvalFactor("a"), EvalFactor("b")]),
Term([EvalFactor("np.log(x)")])
])
Compare to what you get from parsing the above formula:
form2 = ModelDesc.from_formula("y ~ a + a:b + np.log(x)")
24.02.20 22:02, Guido van Rossum пише:
> Hm, that's actually an interesting take. Can you compare it to the kind
> of "quoting" that happens in a lambda? Is there some kind of translation
> of the OP's original example (Lottery ~ Literacy + Wealth + Region) to a
> lambda involving those words?
I think that a named function is more appropriate than a lambda, because
we need also the name of the output parameter:
def Lottery(Literacy, Wealth, Region):
And the most known application of such technique is fixtures in pytest.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/226FMNG77OX4N262QZXFZYZU54LGQJNW/
Code of Conduct: http://python.org/psf/codeofconduct/