Esempio n. 1
0
 def draw_template(self, random, pv):
     if self.element_strategy is None:
         return ()
     length = clamp(self.min_size, dist.geometric(random, 1.0 / (1 + pv.average_length)), self.max_size)
     result = []
     for _ in hrange(length):
         result.append(self.element_strategy.draw_template(random, pv.child_parameter))
     return tuple(result)
Esempio n. 2
0
 def draw_template(self, random, pv):
     if self.element_strategy is None:
         return ()
     length = clamp(
         self.min_size,
         dist.geometric(random, 1.0 / (1 + pv.average_length)),
         self.max_size,
     )
     result = []
     for _ in hrange(length):
         result.append(
             self.element_strategy.draw_template(random,
                                                 pv.child_parameter))
     return tuple(result)
 def adjust_float(self, source, offset):
     return int_to_float(clamp(
         0,
         float_to_int(source) + offset,
         2 ** 64 - 1
     ))
Esempio n. 4
0
 def draw_parameter(self, random):
     return clamp(
         0.0,
         random.random() * 2 / self.average_size,
         1 - 10e-6,
     )
Esempio n. 5
0
def test_clamp():
    assert clamp(None, 1, None) == 1
    assert clamp(None, 10, 1) == 1
    assert clamp(1, 0, 1) == 1
    assert clamp(1, 0, None) == 1
Esempio n. 6
0
 def draw_parameter(self, random):
     return clamp(
         0.0,
         random.random() * 2 / self.average_size,
         1 - 10e-6,
     )
Esempio n. 7
0
def test_clamp():
    assert clamp(None, 1, None) == 1
    assert clamp(None, 10, 1) == 1
    assert clamp(1, 0, 1) == 1
    assert clamp(1, 0, None) == 1
Esempio n. 8
0
 def adjust_float(self, source, offset):
     return int_to_float(clamp(0, float_to_int(source) + offset, 2**64 - 1))