Skip to content

Commit

Permalink
refactor: non-optional missing list
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelZe committed Jan 13, 2024
1 parent c6eebeb commit 8be823c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/tclf/classical_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,17 +398,15 @@ def _nan(self, subset: str) -> npt.NDArray:
"""
return np.full(shape=(self.X_.shape[0],), fill_value=np.nan)

def _validate_columns(self, missing_columns: list | None = None) -> None:
def _validate_columns(self, missing_columns: list) -> None:
"""Validate if all required columns are present.
Args:
missing_columns (list | None): list of missing columns.
missing_columns (list): list of missing columns.
Raises:
ValueError: columns missing in dataframe.
"""
if missing_columns is None:
missing_columns = []
columns = self.columns_ + missing_columns if self.columns_ else missing_columns
self.X_ = pd.DataFrame(np.zeros(shape=(1, len(columns))), columns=columns)
try:
Expand Down Expand Up @@ -499,7 +497,7 @@ def fit(
f"expected one of {ALLOWED_FUNC_STR}."
)

self._validate_columns()
self._validate_columns([])
return self

def predict(self, X: MatrixLike) -> npt.NDArray:
Expand Down

0 comments on commit 8be823c

Please sign in to comment.