Beispiel #1
0
    def _setup(self) -> None:
        if population.count() == 0:
            while population.count() < seq.minimum_bounding_n(
                    config.P_VALUE / max(1, population.count())):
                self._logger.info("Создается базовый организм:")
                org = population.create_new_organism()
                self._logger.info(f"{org}\n")

            self._scale = int(population.count()**0.5)
Beispiel #2
0
def test_get_oldest():
    org = population.create_new_organism()
    org._doc.wins = 1
    org.save()

    org = population.create_new_organism()
    org._doc.wins = 2
    org.save()

    organisms = population.get_all()
    assert isinstance(organisms, Iterable)

    organisms = list(organisms)

    for organism in organisms:
        assert isinstance(organism, population.Organism)

    assert len(list(organisms)) == 6
Beispiel #3
0
def set_test_collection():
    # noinspection PyProtectedMember
    saved_collection = store._COLLECTION
    test_collection = saved_collection.database["test"]
    store._COLLECTION = test_collection

    org = population.create_new_organism()
    org.evaluate_fitness(("TGKBP", "TRNFP"), pd.Timestamp("2020-05-23"))
    org = population.create_new_organism()
    org.evaluate_fitness(("TGKBP", "TRNFP"), pd.Timestamp("2020-05-23"))

    org = population.create_new_organism()
    org.evaluate_fitness(("TGKBP", "TRNFP"), pd.Timestamp("2020-05-22"))

    org = population.create_new_organism()
    org.evaluate_fitness(("AKRN", "TRNFP"), pd.Timestamp("2020-05-23"))

    yield

    store._COLLECTION = saved_collection
    test_collection.drop()
Beispiel #4
0
def get_model_doc():
    # noinspection PyProtectedMember
    saved_collection = store._COLLECTION
    test_collection = saved_collection.database["test"]
    store._COLLECTION = test_collection

    org = population.create_new_organism()
    org.evaluate_fitness(("KRKNP", "NMTP", "TATNP"), pd.Timestamp("2020-05-23"))

    yield org

    store._COLLECTION = saved_collection
    test_collection.drop()
Beispiel #5
0
    def _setup(self) -> NoReturn:
        """Создает популяцию из организмов по умолчанию.

        Если организмов меньше 4 - минимальное количество для осуществления эволюции.
        """
        count = population.count()
        print(f"Имеется {count} организмов из {self._max_population}")
        print()

        if count < 4:
            for i in range(1, self._max_population - count + 1):
                print(f"Создаю базовые генотипы - {i}/{self._max_population - count}")
                organism = population.create_new_organism()
                print(organism)
                print()
Beispiel #6
0
def test_create_new_organism():
    org = population.create_new_organism()
    assert isinstance(org, population.Organism)

    assert population.Organism(_id=org.id).id == org.id
    org.die()