def test_renamer_works_correctly_if_only_given_string(numerical): single_column = numerical.iloc[:, 1].to_frame() renamer = Renamer('test') result = renamer.fit_transform(single_column) assert isinstance(result, pd.DataFrame) assert ['test'] == result.columns assert len(numerical) == len(result)
def test_renamer_returns_correctly(numerical): new_col_names = ['test_a', 'test_b'] renamer = Renamer(new_col_names) result = renamer.fit_transform(numerical) assert isinstance(result, pd.DataFrame) assert len(numerical) == len(result) assert set(new_col_names) == set(result.columns)
def test_mismatched_no_of_names_raises(numerical): new_col_names = ['test_a'] renamer = Renamer(new_col_names) with pytest.raises(TransformerError): renamer.fit_transform(numerical)
def test_renamer_works_gridsearch(self, train_iris_dataset): grid = create_gridsearch(Renamer(["1", "2", "3", "4"])) model = Model(grid) result = model.score_estimator(train_iris_dataset) assert isinstance(result, Result)
def test_renamer_works_in_cv(self, train_iris_dataset): model = create_model(Renamer(["1", "2", "3", "4"])) result = model.score_estimator(train_iris_dataset, cv=2) assert isinstance(result, Result)
def test_mismatched_no_of_names_raises(self, numerical: pd.DataFrame): new_col_names = ["test_a"] renamer = Renamer(new_col_names) with pytest.raises(TransformerError): renamer.fit_transform(numerical)
def test_works_without_args(self): assert Renamer()