Skip to content

Commit fc7ef02

Browse files
author
Brendan Herger
committed
Adding default fill value for constant strategy test
1 parent e0b207e commit fc7ef02

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_categorical_imputer.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,19 @@ def test_invalid_strategy():
162162
"""
163163
with pytest.raises(ValueError):
164164
CategoricalImputer(strategy="not_a_supported_strategy")
165+
166+
167+
@pytest.mark.parametrize('input_type', ['np', 'pd'])
168+
def test_default_fill_value_for_constant_strategy(input_type):
169+
data = ['a', np.nan, 'b', 'b']
170+
171+
if input_type == 'pd':
172+
X = pd.Series(data)
173+
else:
174+
X = np.asarray(data, dtype=object)
175+
176+
imputer = CategoricalImputer(strategy='constant')
177+
Xt = imputer.fit_transform(X)
178+
179+
assert imputer.fill_ == '?'
180+
assert (Xt == ['a', imputer.fill_, 'b', 'b']).all()

0 commit comments

Comments
 (0)