示例#1
0
文件: test_rand.py 项目: ajyoon/blur
 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)])
示例#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)])
示例#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)])
示例#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)])
示例#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)
示例#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)
示例#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)
示例#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)
示例#9
0
文件: test_rand.py 项目: ajyoon/blur
 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))
示例#10
0
文件: test_rand.py 项目: ajyoon/blur
 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)])
示例#11
0
文件: test_rand.py 项目: ajyoon/blur
 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)])
示例#12
0
文件: test_rand.py 项目: ajyoon/blur
 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)
示例#13
0
文件: test_rand.py 项目: ajyoon/blur
 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)
示例#14
0
文件: test_rand.py 项目: ajyoon/blur
 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))
示例#15
0
文件: test_rand.py 项目: ajyoon/blur
 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)