Commit b0ee5ef
committed
FIX: showstopper bug with NA handling and data-independent builders
Some formulas, like "~ 1", don't actually depend on the passed-in
data. So given a formula like "y ~ 1", what we do is build the y
matrix for the LHS, and then build a 1x1 matrix for the RHS, and then
broadcast the RHS matrix to match the left. However, this broadcasting
logic was broadcasting to the *original* size of the LHS matrix,
*before* NA removal.
One result: expressions like dmatrices("y ~ 1") were returning
matrices with different numbers of rows, whenever y had missing
values.
Another result: dmatrix(..., result_type="dataframe") was totally
broken in the presence of NAs, because RHS-only formulas still have an
invisible zero-column LHS which is calculated and then discarded. But
this was calculated with the wrong number of rows, and then when we
tried to convert it to a zero-column DataFrame, its shape didn't match
the index that we tried to put on it. (Because NA removal *was*
correctly affecting the index.)
Fixes pydatagh-22.1 parent 3048399 commit b0ee5ef
2 files changed
+37
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
918 | 918 | | |
919 | 919 | | |
920 | 920 | | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
921 | 924 | | |
922 | 925 | | |
923 | 926 | | |
924 | 927 | | |
925 | 928 | | |
926 | 929 | | |
927 | 930 | | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
928 | 934 | | |
929 | 935 | | |
930 | 936 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
645 | 645 | | |
646 | 646 | | |
647 | 647 | | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
0 commit comments