Ejemplo n.º 1
0
 def test_bound_weights_with_only_one_bound(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     # With only minimum
     self.assertEqual(rand.bound_weights(weights, minimum=1),
                      [(1, 1), (2, 2), (4, 2), (6, 0)])
     # With only maximum
     self.assertEqual(rand.bound_weights(weights, maximum=5),
                      [(0, 0), (2, 2), (4, 2), (5, 1)])
Ejemplo n.º 2
0
 def test_bound_weights_with_only_one_bound(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     # With only minimum
     self.assertEqual(rand.bound_weights(weights, minimum=1),
                      [(1, 1), (2, 2), (4, 2), (6, 0)])
     # With only maximum
     self.assertEqual(rand.bound_weights(weights, maximum=5),
                      [(0, 0), (2, 2), (4, 2), (5, 1)])
Ejemplo n.º 3
0
 def test_bound_weights_clipping_between_existing_weights(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     self.assertEqual(rand.bound_weights(weights, 1, 5),
                      [(1, 1), (2, 2), (4, 2), (5, 1)])
Ejemplo n.º 4
0
 def test_bound_weights_clipping_on_existing_weights(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     self.assertEqual(rand.bound_weights(weights, 2, 4),
                      [(2, 2), (4, 2)])
Ejemplo n.º 5
0
 def test_bound_weights_with_weights_already_inside_bounds(self):
     # When all weights are already inside bounds,
     # rand.bound_weights() should have no effect
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     modified = rand.bound_weights(weights, -2, 8)
     self.assertEqual(weights, modified)
Ejemplo n.º 6
0
 def test_bound_weights_doesnt_modify_input(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     original_weights = weights[:]
     modified = rand.bound_weights(weights, 2, 4)
     self.assertEqual(weights, original_weights)
Ejemplo n.º 7
0
 def test_bound_weights_without_bounds_raises_TypeError(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     with self.assertRaises(TypeError):
         rand.bound_weights(weights)
Ejemplo n.º 8
0
 def test_bound_weights_with_bad_bounds_raises_ValueError(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     with self.assertRaises(ValueError):
         rand.bound_weights(weights, 10, 5)
Ejemplo n.º 9
0
 def test_bound_weights_without_bounds_returns_unmodified(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     self.assertEqual(weights, rand.bound_weights(weights))
Ejemplo n.º 10
0
 def test_bound_weights_clipping_between_existing_weights(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     self.assertEqual(rand.bound_weights(weights, 1, 5), [(1, 1), (2, 2),
                                                          (4, 2), (5, 1)])
Ejemplo n.º 11
0
 def test_bound_weights_clipping_on_existing_weights(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     self.assertEqual(rand.bound_weights(weights, 2, 4), [(2, 2), (4, 2)])
Ejemplo n.º 12
0
 def test_bound_weights_with_weights_already_inside_bounds(self):
     # When all weights are already inside bounds,
     # rand.bound_weights() should have no effect
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     modified = rand.bound_weights(weights, -2, 8)
     self.assertEqual(weights, modified)
Ejemplo n.º 13
0
 def test_bound_weights_doesnt_modify_input(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     original_weights = weights[:]
     rand.bound_weights(weights, 2, 4)
     self.assertEqual(weights, original_weights)
Ejemplo n.º 14
0
 def test_bound_weights_without_bounds_returns_unmodified(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     self.assertEqual(weights, rand.bound_weights(weights))
Ejemplo n.º 15
0
 def test_bound_weights_with_bad_bounds_raises_ValueError(self):
     weights = [(0, 0), (2, 2), (4, 2), (6, 0)]
     with self.assertRaises(ValueError):
         rand.bound_weights(weights, 10, 5)