From 8be823caeb0f6e35d7d84297057f3d77a1ffa090 Mon Sep 17 00:00:00 2001 From: Markus Bilz Date: Sat, 13 Jan 2024 08:53:04 +0100 Subject: [PATCH] refactor: non-optional missing list --- src/tclf/classical_classifier.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/tclf/classical_classifier.py b/src/tclf/classical_classifier.py index 75d9fc4..f0a090c 100644 --- a/src/tclf/classical_classifier.py +++ b/src/tclf/classical_classifier.py @@ -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: @@ -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: