Exemplo n.º 1
0
 def test_split_in_three_unequal(self):
     """Tests a simple linear split into three unequal pieces."""
     i = 0
     expected = [0, 0, 0, 1, 1, 2, 2, 2, 2, 2]
     for partition in partitioner(10, [1, 1, 2],
                                  LinearFakeRandomFunction(10)):
         self.assertEqual(expected[i], partition)
         i += 1
Exemplo n.º 2
0
 def __init__(self,
              dataset,
              training_percent=0.8,
              partitioning_function=pseudorandom_function):
     self.dataset = dataset
     self.training_percent = training_percent
     self.n_of_elements = len(dataset)
     self.partitioner = partitioner(
         self.n_of_elements,
         [training_percent, 1 - training_percent],
         partitioning_function,
     )
     self.test_indexes = []
     self.training_indexes = []
     self.index = 0
Exemplo n.º 3
0
 def test_split_in_two(self):
     """Tests a simple linear split into two pieces."""
     i = 0
     for partition in partitioner(10, [1, 1], LinearFakeRandomFunction(10)):
         self.assertEqual(i // 5, partition)
         i += 1
Exemplo n.º 4
0
 def test_non_positive_n_of_elements(self):
     """Assert that using a weight thats' not positive is a failure."""
     with self.assertRaises(AssertionError):
         partitioner(0, [1, 1]).__next__()
Exemplo n.º 5
0
 def test_weight_sum_0(self):
     """Assert that using a weight thats' not positive is a failure."""
     with self.assertRaises(AssertionError):
         partitioner(10, [0, 0]).__next__()