def test_faker_generator_should_delegate_to_faker_correct():

    tested_name = FakerGenerator(seed=1234, method="name")
    some_names = tested_name.generate(10)
    assert len(some_names) == 10

    tested_text = FakerGenerator(seed=1234, method="text")
    some_text = tested_text.generate(20)
    assert len(some_text) == 20

    tested_address = FakerGenerator(seed=1234, method="address")
    some_addresses = tested_address.generate(30)
    assert len(some_addresses) == 30
def add_quotes(the_circus):

    quote_generator = FakerGenerator(method="sentence",
                                     nb_words=6,
                                     variable_nb_words=True,
                                     seed=next(the_circus.seeder))

    person = the_circus.populations["person"]

    quotes_rel = person.create_relationship("quotes")

    for _ in range(4):
        quotes_rel.add_relations(
            from_ids=person.ids,
            to_ids=quote_generator.generate(size=person.size)
        )
Beispiel #3
0
def build_uganda_populations(circus):

    seeder = seed_provider(12345)

    cells = circus.create_population(
        name="cells", ids_gen=SequencialGenerator(prefix="CELL_"), size=200)
    latitude_generator = FakerGenerator(method="latitude", seed=next(seeder))
    cells.create_attribute("latitude", init_gen=latitude_generator)

    longitude_generator = FakerGenerator(method="longitude", seed=next(seeder))
    cells.create_attribute("longitude", init_gen=longitude_generator)

    # the cell "health" is its probability of accepting a call. By default
    # let's says it's one expected failure every 1000 calls
    healthy_level_gen = build_healthy_level_gen(next(seeder))

    cells.create_attribute(name="HEALTH", init_gen=healthy_level_gen)

    city_gen = FakerGenerator(method="city", seed=next(seeder))
    cities_values = pd.unique(city_gen.generate(500))[:200]
    cities = circus.create_population(name="cities", ids=cities_values)

    cell_city_rel = cities.create_relationship("CELLS")

    cell_city_df = make_random_assign(cells.ids, cities.ids, next(seeder))
    cell_city_rel.add_relations(from_ids=cell_city_df["chosen_from_set2"],
                                to_ids=cell_city_df["set1"])

    pop_gen = ParetoGenerator(xmin=10000, a=1.4, seed=next(seeder))
    cities.create_attribute("population", init_gen=pop_gen)

    timer_config = CyclicTimerProfile(
        profile=[
            1, .5, .2, .15, .2, .4, 3.8, 7.2, 8.4, 9.1, 9.0, 8.3, 8.1, 7.7,
            7.4, 7.8, 8.0, 7.9, 9.7, 10.4, 10.5, 8.8, 5.7, 2.8
        ],
        profile_time_steps="1h",
        start_date=pd.Timestamp("6 June 2016 00:00:00"))

    return cells, cities, timer_config
Beispiel #4
0
    def _add_person_population(self):

        id_gen = SequencialGenerator(prefix="PERSON_")
        age_gen = NumpyRandomGenerator(method="normal", loc=3, scale=5,
                                       seed=next(self.seeder))
        name_gen = FakerGenerator(method="name", seed=next(self.seeder))

        person = self.create_population(name="person", size=1000, ids_gen=id_gen)
        person.create_attribute("NAME", init_gen=name_gen)
        person.create_attribute("AGE", init_gen=age_gen)

        quote_generator = FakerGenerator(method="sentence", nb_words=6, variable_nb_words=True,
                                         seed=next(self.seeder))

        quotes_rel = self.populations["person"].create_relationship("quotes")

        for w in range(4):
            quotes_rel.add_relations(
                from_ids=person.ids,
                to_ids=quote_generator.generate(size=person.size),
                weights=w
            )
Beispiel #5
0
                                          ids_gen=id_gen)
person.create_attribute("NAME", init_gen=name_gen)
person.create_attribute("AGE", init_gen=age_gen)

# basic relationship to store people's quote

quote_generator = FakerGenerator(method="sentence",
                                 nb_words=6,
                                 variable_nb_words=True,
                                 seed=next(example_circus.seeder))

quotes_rel = example_circus.populations["person"].create_relationship("quotes")

for w in range(4):
    quotes_rel.add_relations(from_ids=person.ids,
                             to_ids=quote_generator.generate(size=person.size),
                             weights=w)

# message story

story_timer_gen = DefaultDailyTimerGenerator(clock=example_circus.clock,
                                             seed=next(example_circus.seeder))

low_activity = story_timer_gen.activity(n=3, per=pd.Timedelta("1 day"))
med_activity = story_timer_gen.activity(n=10, per=pd.Timedelta("1 day"))
high_activity = story_timer_gen.activity(n=20, per=pd.Timedelta("1 day"))

activity_gen = NumpyRandomGenerator(
    method="choice",
    a=[low_activity, med_activity, high_activity],
    p=[.2, .7, .1],