def test_sort_distributions_alphabetical(self):
     """Test correctly sorts distributions alphabetically."""
     exp = [([2, 1, 1], [1, 2, 3], [0, 0, 0, 1], [1]),
            ('baz', 'foo', 'foo', 'zab'), ('r', 'w', 'b', 'b')]
     obs = _sort_distributions(
         [[1, 2, 3], [2, 1, 1], [0, 0, 0, 1], [1]],
         ['foo', 'baz', 'foo', 'zab'], ['w', 'r', 'b', 'b'], 'alphabetical')
     self.assertEqual(obs, exp)
 def test_sort_distributions_median(self):
     """Test correctly sorts distributions by median."""
     exp = [([0, 0, 0, 1], [2, 1, 1], [1], [1, 2, 3]),
            ('bar', 'baz', 'zab', 'foo'), ('b', 'r', 'b', 'w')]
     obs = _sort_distributions(
         [[1, 2, 3], [2, 1, 1], [0, 0, 0, 1], [1]],
         ['foo', 'baz', 'bar', 'zab'], ['w', 'r', 'b', 'b'], 'median')
     self.assertEqual(obs, exp)
예제 #3
0
 def test_sort_distributions_alphabetical(self):
     """Test correctly sorts distributions alphabetically."""
     exp = [([2, 1, 1], [1, 2, 3], [0, 0, 0, 1], [1]),
            ('baz', 'foo', 'foo', 'zab'), ('r', 'w', 'b', 'b')]
     obs = _sort_distributions([[1, 2, 3], [2, 1, 1], [0, 0, 0, 1], [1]],
                               ['foo', 'baz', 'foo', 'zab'],
                               ['w', 'r', 'b', 'b'], 'alphabetical')
     self.assertEqual(obs, exp)
예제 #4
0
 def test_sort_distributions_median(self):
     """Test correctly sorts distributions by median."""
     exp = [([0, 0, 0, 1], [2, 1, 1], [1], [1, 2, 3]),
            ('bar', 'baz', 'zab', 'foo'), ('b', 'r', 'b', 'w')]
     obs = _sort_distributions([[1, 2, 3], [2, 1, 1], [0, 0, 0, 1], [1]],
                               ['foo', 'baz', 'bar', 'zab'],
                               ['w', 'r', 'b', 'b'], 'median')
     self.assertEqual(obs, exp)
 def test_sort_distributions_invalid_input(self):
     """Correctly raises error on invalid input."""
     # Unfortunately, this code doesn't support the brosort algorithm... :(
     with self.assertRaises(ValueError):
         _ = _sort_distributions([[1, 2, 3], [3, 2, 1]], ['foo', 'bar'],
                                 ['r', 'b'], 'brosort')
예제 #6
0
 def test_sort_distributions_invalid_input(self):
     """Correctly raises error on invalid input."""
     # Unfortunately, this code doesn't support the brosort algorithm... :(
     with self.assertRaises(ValueError):
         _ = _sort_distributions([[1, 2, 3], [3, 2, 1]], ['foo', 'bar'],
                                 ['r', 'b'], 'brosort')