Example #1
0
 def draw_parameter(self, random):
     return self.Parameter(
         p_hour=dist.uniform_float(random, 0, 1),
         p_minute=dist.uniform_float(random, 0, 1),
         p_second=dist.uniform_float(random, 0, 1),
         month=dist.non_empty_subset(random, list(range(1, 13))),
         naive_chance=dist.uniform_float(random, 0, 0.5),
         timezones=self.timezones and dist.non_empty_subset(random, self.timezones),
     )
Example #2
0
 def draw_parameter(self, random):
     return self.Parameter(
         p_hour=dist.uniform_float(random, 0, 1),
         p_minute=dist.uniform_float(random, 0, 1),
         p_second=dist.uniform_float(random, 0, 1),
         month=dist.non_empty_subset(random, list(range(1, 13))),
         naive_chance=dist.uniform_float(random, 0, 0.5),
         timezones=self.timezones
         and dist.non_empty_subset(random, self.timezones),
     )
Example #3
0
 def produce_parameter(self, random):
     return self.Parameter(
         p_hour=dist.uniform_float(random, 0, 1),
         p_minute=dist.uniform_float(random, 0, 1),
         p_second=dist.uniform_float(random, 0, 1),
         month=dist.non_empty_subset(random, list(range(1, 13))),
         naive_chance=dist.uniform_float(random, 0, 0.5),
         utc_chance=dist.uniform_float(random, 0, 1),
         timezones=dist.non_empty_subset(
             random, list(map(pytz.timezone, pytz.all_timezones))),
         naive_options=dist.non_empty_subset(random, self.naive_options))
Example #4
0
 def draw_parameter(self, random):
     locales = dist.non_empty_subset(random, self.locales)
     n = 1 + geometric(random, 0.1)
     return [
         self.gen_example(random, locales)
         for _ in hrange(n)
     ]
Example #5
0
 def draw_parameter(self, random):
     locales = dist.non_empty_subset(random, self.locales)
     n = 1 + geometric(random, 0.1)
     return [
         self.gen_example(random, locales)
         for _ in hrange(n)
     ]
Example #6
0
 def produce_parameter(self, random):
     return self.Parameter(
         p_hour=dist.uniform_float(random, 0, 1),
         p_minute=dist.uniform_float(random, 0, 1),
         p_second=dist.uniform_float(random, 0, 1),
         month=dist.non_empty_subset(random, list(range(1, 13))),
         naive_chance=dist.uniform_float(random, 0, 0.5),
         utc_chance=dist.uniform_float(random, 0, 1),
         timezones=dist.non_empty_subset(
             random,
             list(
                 map(pytz.timezone, pytz.all_timezones))
         ),
         naive_options=dist.non_empty_subset(random,
                                             self.naive_options
                                             )
     )
Example #7
0
 def produce_parameter(self, random):
     indices = list(range(len(self.element_strategies)))
     enabled = dist.non_empty_subset(random,
                                     indices,
                                     activation_chance=(1.0 / len(indices)))
     return self.Parameter(
         enabled_children=enabled,
         child_parameters=[
             self.element_strategies[i].draw_parameter(random)
             if i in enabled else None for i in indices
         ])
Example #8
0
 def produce_parameter(self, random):
     indices = list(range(len(self.element_strategies)))
     enabled = dist.non_empty_subset(
         random,
         indices,
     )
     return self.Parameter(
         enabled_children=enabled,
         child_parameters=[
             self.element_strategies[i].draw_parameter(random)
             if i in enabled else None
             for i in indices
         ]
     )
Example #9
0
def test_non_empty_of_empty_errors():
    with pytest.raises(ValueError):
        dist.non_empty_subset(random, [])
Example #10
0
 def produce_parameter(self, random):
     return dist.non_empty_subset(
         random,
         tuple(range(self.start, self.end + 1)),
         activation_chance=min(0.5, 3.0 / (self.end - self.start + 1))
     )
def test_non_empty_of_10():
    assert dist.non_empty_subset(random, range(10))
def test_non_empty_of_one_always_returns_it():
    assert dist.non_empty_subset(random, [1]) == [1]
    assert dist.non_empty_subset(random, [2]) == [2]
Example #13
0
def test_non_empty_of_three():
    assert dist.non_empty_subset(random, [1, 2, 3])
Example #14
0
 def produce_parameter(self, random):
     return dist.non_empty_subset(
         random,
         tuple(range(self.start, self.end + 1)),
         activation_chance=min(0.5, 3.0 / (self.end - self.start + 1))
     )
Example #15
0
 def produce_parameter(self, random):
     return dist.non_empty_subset(random, range(len(self.elements)))
Example #16
0
def test_non_empty_of_one_always_returns_it():
    assert dist.non_empty_subset(random, [1]) == [1]
    assert dist.non_empty_subset(random, [2]) == [2]
Example #17
0
def test_non_empty_of_10():
    assert dist.non_empty_subset(random, range(10))
Example #18
0
def test_non_empty_with_explicit_activation_chance():
    assert len(
        dist.non_empty_subset(random, range(100), activation_chance=0.99)) > 2
def test_non_empty_of_empty_errors():
    with pytest.raises(ValueError):
        dist.non_empty_subset(random, [])
Example #20
0
 def draw_parameter(self, random):
     return dist.non_empty_subset(random, self.locales)
def test_non_empty_of_three():
    assert dist.non_empty_subset(random, [1, 2, 3])
Example #22
0
 def produce_parameter(self, random):
     return dist.non_empty_subset(random, self.locales)
def test_non_empty_with_explicit_activation_chance():
    assert len(dist.non_empty_subset(
        random, range(100), activation_chance=0.99)) > 2
Example #24
0
 def produce_parameter(self, random):
     return dist.non_empty_subset(random, range(len(self.elements)))