Esempio n. 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),
     )
Esempio n. 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),
     )
Esempio n. 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))
Esempio n. 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)
     ]
Esempio n. 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)
     ]
Esempio n. 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
                                             )
     )
Esempio n. 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
         ])
Esempio n. 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
         ]
     )
Esempio n. 9
0
def test_non_empty_of_empty_errors():
    with pytest.raises(ValueError):
        dist.non_empty_subset(random, [])
Esempio n. 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]
Esempio n. 13
0
def test_non_empty_of_three():
    assert dist.non_empty_subset(random, [1, 2, 3])
Esempio n. 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))
     )
Esempio n. 15
0
 def produce_parameter(self, random):
     return dist.non_empty_subset(random, range(len(self.elements)))
Esempio n. 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]
Esempio n. 17
0
def test_non_empty_of_10():
    assert dist.non_empty_subset(random, range(10))
Esempio n. 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, [])
Esempio n. 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])
Esempio n. 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
Esempio n. 24
0
 def produce_parameter(self, random):
     return dist.non_empty_subset(random, range(len(self.elements)))