Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imp: adds formula primitive type #10

Open
lizgehret opened this issue Oct 13, 2022 · 0 comments
Open

imp: adds formula primitive type #10

lizgehret opened this issue Oct 13, 2022 · 0 comments
Assignees

Comments

@lizgehret
Copy link
Member

Add primitive type in q2-stats and the framework for the following (currently in q2-composition under ANCOM-BC method):

def _parse_terms(formula):
    parse = formulaic.parser.parser.DefaultFormulaParser(include_intercept=False)
    terms = parse.get_ast(formula=formula).flatten()
    formula_terms = _leaf_collector(terms)
    return formula_terms

def _leaf_collector(term):
    if isinstance(term, formulaic.parser.types.Token):
        return [str(term)]

    if type(term) is not list:
        return []

    return _leaf_collector(term[1]) + _leaf_collector(term[2])
@lizgehret lizgehret self-assigned this Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant