matthewwardrop / formulaic

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

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

Closed hguturu closed 9 months ago

hguturu commented 9 months 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 9 months 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 9 months ago

Fixed by 2f0a480641aba40d0fc3783797110165baeaddf0