def test_default_sklearn_params_call(self): tt = r.SklearnCreator(SklearnCreatorTest.T(a=2), keep_original=True) t = tt(a=3) d = t.sk_transformer.get_params() d_expected = {"a": 3, "b": 1} self.assertDictEqual(d, d_expected)
def test_default_sklearn_params(self): tt = r.SklearnCreator(SklearnCreatorTest.T(a=2)) t = tt() d = t.sk_transformer.get_params() d_expected = {"a": 2, "b": 1} self.assertEqual(d, d_expected)
def test_param_collision(self): """Use sk_params when an Sklearn object has the same attr. """ class T(SklearnTransformerMock): def __init__(self, keep_original=0): self.keep_original = keep_original tt = r.SklearnCreator(T()) t = tt(keep_original=3, sk_params=dict(keep_original=2)) self.assertEqual(t.sk_transformer.keep_original, 2) self.assertEqual(t.keep_original, 3)
def test_wrapper_error(self): tt = r.SklearnCreator(SklearnCreatorTest.T()) with self.assertRaisesRegex(ValueError, "Wrapper method not in.*"): t = tt(wrapper="daisy")
def test_wrapper_column(self): tt = r.SklearnCreator(SklearnCreatorTest.T()) t = tt(wrapper="column") self.assertTrue(isinstance(t, r.SklearnColumnWrapper))
def test_wrapper_default(self): tt = r.SklearnCreator(SklearnCreatorTest.T()) t = tt() self.assertTrue(isinstance(t, r.SklearnColumnsWrapper))
def test_default_recipipe_params_call(self): """Call recipipe params should overwrite existing default params. """ tt = r.SklearnCreator(SklearnCreatorTest.T(), keep_original=True) t = tt(keep_original=False) self.assertFalse(t.keep_original)
def test_default_recipipe_params(self): """By default keep_original is False, test that True is maintained. """ tt = r.SklearnCreator(SklearnCreatorTest.T(), keep_original=True) t = tt() self.assertTrue(t.keep_original)