Skip to content

Commit 1e65143

Browse files
committed
Fixed the type hint for _generate_inverted_hierarchy.
Removed ToDo comment based on feedback. Added type hint to test_hierarchy_with_scikit_learn_column_transformer.
1 parent 106af76 commit 1e65143

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

category_encoders/target_encoder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ def _weighting(self, n: int) -> float:
312312
# sigmoid in this case, using scipy.expit for numerical stability
313313
return expit((n - self.min_samples_leaf) / self.smoothing)
314314

315-
def _generate_inverted_hierarchy(self) -> tuple[dict | pd.DataFrame, dict]:
316-
# @ToDo create a function to check the hierarchy
315+
def _generate_inverted_hierarchy(self) -> tuple[dict | pd.DataFrame | None, dict]:
317316
if isinstance(self.hierarchy, (dict, pd.DataFrame)) and self.cols is None:
318317
raise ValueError('Hierarchy is defined but no columns are named for encoding')
319318
if isinstance(self.hierarchy, dict):

tests/test_target_encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def test_hierarchy_mapping_cols_missing(self):
507507
with self.assertRaises(ValueError):
508508
enc.fit_transform(X, y)
509509

510-
def test_hierarchy_with_scikit_learn_column_transformer(self):
510+
def test_hierarchy_with_scikit_learn_column_transformer(self) -> None:
511511
"""Test that the encoder works with a scikit-learn ColumnTransformer."""
512512
features: list[str] = ["cat_feature", "int_feature"]
513513
target: str = "target"

0 commit comments

Comments
 (0)