matthewwardrop / formulaic

A high-performance implementation of Wilkinson formulas for Python.
MIT License
345 stars 25 forks source link

Throw error when formula has parameters that are not available #159

Closed hguturu closed 1 year ago

hguturu commented 1 year ago

E..g.

formulaic.model_matrix(["1+BinGrpe"],phenotypes)
where
phenotypes =  all_phenotypes = pd.DataFrame({ "AltGrp": [1, 0, 0, 1, 0, 1], "BinGrp": [0, 0, 0, 1, 1, 1], "ContGrp" : [1,2,3,4,5,6]})

yields

   Intercept
0        1.0
1        1.0
2        1.0
3        1.0
4        1.0
5        1.0

Where the typo in BinGrpe is silently ignored. I think it would be safer if an error or warning is thrown here.

matthewwardrop commented 1 year ago

This is a regression introduced in a recent release (is broken in 0.6.4+). Will make sure this gets patched. Thanks for reporting.

matthewwardrop commented 1 year ago

Fixed by 2f0a480641aba40d0fc3783797110165baeaddf0