Skip to content

Extend ignored columns test to cover np.nan and pd.NA cases - #472

Open
manishaagangadevi wants to merge 1 commit into
scikit-learn-contrib:masterfrom
manishaagangadevi:master
Open

Extend ignored columns test to cover np.nan and pd.NA cases#472
manishaagangadevi wants to merge 1 commit into
scikit-learn-contrib:masterfrom
manishaagangadevi:master

Conversation

@manishaagangadevi

Copy link
Copy Markdown

Description

This pull request extends the existing test test_ignored_columns_are_untouched
to additionally verify that ignored columns remain unchanged when containing
np.nan and pd.NA values.

The existing test already checks behaviour for None values. This change ensures
consistent handling of other common missing value representations in pandas.

Changes Made

  • Added test cases for np.nan values in ignored columns
  • Added test cases for pd.NA values in ignored columns
  • Ensured ignored columns remain unchanged after encoding

Comment thread tests/test_encoders.py
enc = getattr(encoders, encoder_name)(cols=['col1'])
out = enc.fit_transform(X, y)
self.assertTrue(out.col2[2] is None)
self.assertTrue(pd.isna(out.col2.iloc[2]))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you want to relax the check from is None to pd.isna? the precise point of this test is checking that it is still a python None

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification.

You’re right, the original test is meant to check that the value stays strictly None. I was trying to extend the test to also cover cases with np.nan and pd.NA, but I realise now that replacing the original assertion changes the intent of the test.
I’ll revert the strict None check and instead add separate tests for np.nan and pd.NA while keeping the original behaviour unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants