Esempio 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)])
Esempio 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)])
Esempio 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)])
Esempio 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)])
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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))
Esempio 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)])
Esempio 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)])
Esempio 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)
Esempio 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)
Esempio 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))
Esempio 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)