Skip to content

Commit

Permalink
Adjust tests to new pandas behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
stanmart committed Dec 2, 2024
1 parent 96aab71 commit 2bbb082
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_formula.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,19 +480,29 @@ def test_all_names_against_from_pandas(df, categorical_format):
pytest.param(
"1 + C(cat_1, spans_intercept=False) * cat_2 * cat_3",
id="custom_contrasts",
marks=pytest.mark.xfail(
reason="Non-uniform categorical formats are not yet supported"
),
),
],
)
def test_names_against_pandas(df, formula, ensure_full_rank):
if ensure_full_rank:
categorical_format = "{name}[T.{category}]"
else:
categorical_format = "{name}[{category}]"

num_in_scope = 2 # noqa

model_df = formulaic.model_matrix(formula, df, ensure_full_rank=ensure_full_rank)
model_tabmat = tm.from_formula(
formula,
df,
ensure_full_rank=ensure_full_rank,
categorical_format="{name}[T.{category}]",
categorical_format=categorical_format,
context=0,
)

assert model_tabmat.model_spec.column_names == model_df.model_spec.column_names
assert model_tabmat.model_spec.column_names == tuple(model_df.columns)
assert model_tabmat.column_names == list(model_df.columns)
Expand Down

0 comments on commit 2bbb082

Please sign in to comment.