Skip to content

Commit

Permalink
Add comment about dropping missings in tests for new levels
Browse files Browse the repository at this point in the history
  • Loading branch information
stanmart committed Jan 25, 2024
1 parent c0d4dea commit 2644d31
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tabmat/formula.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ def encode_contrasts(
# Check for unseen categories when levels are specified
if levels is not None:
if missing_method == "convert" and not add_missing_category:
# We only need to include NAs in the check in this case because:
# - missing_method == "fail" raises a more appropriate error later
# - missings are no problem in the other cases
unseen_categories = set(data.unique()) - set(levels)
else:
unseen_categories = set(data.dropna().unique()) - set(levels)
Expand Down

0 comments on commit 2644d31

Please sign in to comment.