Ejemplo n.º 1
0
 def valid_generated_helper(self, t):
     random.seed(1)
     lo, hi = -10, 10
     iv = IndependentVariable(lo, hi, t)
     for _ in range(50):
         x = iv()
         assert_true(lo <= x <= hi)
         assert_is_instance(x, t)
Ejemplo n.º 2
0
 def test_clipping_in(self):
     iv = IndependentVariable(0, 10)
     assert_equal(iv.clip(4.2), 4.2)
Ejemplo n.º 3
0
 def test_clipping_lo(self):
     iv = IndependentVariable(0, 10)
     assert_equal(iv.clip(-100), 0)
Ejemplo n.º 4
0
 def test_clipping_hi(self):
     iv = IndependentVariable(0, 10)
     assert_equal(iv.clip(10.5), 10)
Ejemplo n.º 5
0
 def test_init_default(self):
     lo, hi = 0, 10
     iv = IndependentVariable(lo, hi)
     assert_equal(iv.lo, lo)
     assert_equal(iv.hi, hi)
     assert_equal(iv.type, float)
Ejemplo n.º 6
0
 def test_init_type(self):
     lo, hi = 0, 10
     iv = IndependentVariable(lo, hi, int)
     assert_equal(iv.lo, lo)
     assert_equal(iv.hi, hi)
     assert_equal(iv.type, int)
Ejemplo n.º 7
0
 def test_output_with_string_valid_inputs(self):
     valid = {'hello', 'and', 'welcome'}
     iv = IndependentVariable(valid_inputs=valid)
     for x in [iv() for _ in range(30)]:
         assert_in(x, valid)
Ejemplo n.º 8
0
 def test_init_type_with_string_valid_inputs(self):
     iv = IndependentVariable(valid_inputs=('hello', 'and', 'welcome'))
     assert_equal(iv.type, str)
Ejemplo n.º 9
0
 def test_clipping_in(self):
     iv = IndependentVariable(0, 10)
     assert_equal(iv.clip(4.2), 4.2)
Ejemplo n.º 10
0
 def test_clipping_lo(self):
     iv = IndependentVariable(0, 10)
     assert_equal(iv.clip(-100), 0)
Ejemplo n.º 11
0
 def test_clipping_hi(self):
     iv = IndependentVariable(0, 10)
     assert_equal(iv.clip(10.5), 10)