def test_onehot_encode_performance(self): encoder = OneHotEncoder(list(range(1000)), err_if_unknown=False) to_encode = [100, 200, 300, 400, -1] * 100000 time = min( timeit.repeat(lambda: encoder.encodes(to_encode), repeat=25, number=1)) #best observed 0.027 self.assertLess(time, .27)
def test_init_values(self): encoder = OneHotEncoder(values=["0", "1", "2"]) self.assertEqual(True, encoder.is_fit) self.assertEqual([(1, 0, 0), (0, 1, 0), (0, 0, 1), (0, 1, 0)], encoder.encodes(["0", "1", "2", "1"]))