Skip to content

Conversation

@leostimpfle
Copy link
Collaborator

This is a proof of concept for a refactor of PyFixest's formula parsing. The PR introduces a new module parse that refactors formula parsing from the ground up.

The core logic is implemented in pyfixest.estimation.formula.parse.parse which takes in a formula string and returns a collection of parsed formulas represented by pyfixest.estimation.formula.parse.Formula.

All references to the old FormulaParser are bypassed (mostly by renaming the old FixestFormula using imports of the form from pyfixest.estimation.formula.parse import Formula as FixestFormula)

@codecov
Copy link

codecov bot commented Dec 28, 2025

Codecov Report

❌ Patch coverage is 87.06140% with 59 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pyfixest/estimation/formula/factor_interaction.py 63.41% 30 Missing ⚠️
pyfixest/estimation/formula/parse.py 92.39% 14 Missing ⚠️
pyfixest/estimation/formula/model_matrix.py 92.92% 8 Missing ⚠️
pyfixest/estimation/formula/utils.py 33.33% 6 Missing ⚠️
pyfixest/estimation/model_matrix_fixest_.py 80.00% 1 Missing ⚠️
Flag Coverage Δ
core-tests 72.65% <87.06%> (-2.25%) ⬇️
tests-extended ?
tests-vs-r ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pyfixest/did/did2s.py 89.62% <100.00%> (ø)
pyfixest/errors/__init__.py 100.00% <100.00%> (ø)
pyfixest/estimation/FixestMulti_.py 77.95% <100.00%> (-0.24%) ⬇️
pyfixest/estimation/__init__.py 100.00% <100.00%> (ø)
pyfixest/estimation/fegaussian_.py 86.66% <100.00%> (ø)
pyfixest/estimation/feglm_.py 79.16% <100.00%> (ø)
pyfixest/estimation/feiv_.py 86.79% <100.00%> (ø)
pyfixest/estimation/felogit_.py 88.23% <100.00%> (ø)
pyfixest/estimation/feols_.py 86.80% <100.00%> (-4.59%) ⬇️
pyfixest/estimation/feols_compressed_.py 80.00% <100.00%> (ø)
... and 10 more

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@s3alfisc
Copy link
Member

After first look at the code base: much better and much cleaner than before. No fundamental suggestions for improvement from my side. Thank you!

@leostimpfle
Copy link
Collaborator Author

Note to self: Look into allowing formulaic's multi stage formula notation in the parser. For more background see matthewwardrop/formulaic#108 and matthewwardrop/formulaic#24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants