def test_eaten_enough():
    """Test that a carnivore won't eat if its parameter ['F'] is 0."""
    carn = Carnivore(5, 20)
    carn_weight = carn.weight
    herbs = [Herbivore(6, 20), Herbivore(6, 20), Herbivore(6, 20)]
    carn.set_params({"F": 0})

    assert carn.eat(herbs)
    assert carn.weight == carn_weight
def test_eat_if_deltaphimax_low(mocker):
    """Test that if DeltaPhiMax parameter is lower than the difference in fitness, the carnivore
     eats"""
    mocker.patch("numpy.random.random", return_value=0)
    carn = Carnivore(5, 20)
    herb = [Herbivore(6, 20)]
    carn.set_params({"DeltaPhiMax": 0.0001})
    carn.eat(herb)
    assert carn.weight != 20
    assert carn.weight == 35
    def set_animal_parameters(species, params):
        """Set parameters for animal species.

        Parameters
        ----------
        species : str
               String, name of animal species

        params : dict
               Dict with valid parameter specification for species
        """
        if species == "Herbivore":
            Herbivore.set_params(params)
        elif species == "Carnivore":
            Carnivore.set_params(params)
def test_set_animal_parameters():
    """Sets default parameters to animals for the tests"""
    Herbivore.set_params(
        {
            "w_birth": 8.0,
            "sigma_birth": 1.5,
            "beta": 0.9,
            "eta": 0.05,
            "a_half": 40.0,
            "phi_age": 0.6,
            "w_half": 10.0,
            "phi_weight": 0.1,
            "mu": 0.25,
            "gamma": 0.2,
            "zeta": 3.5,
            "xi": 1.2,
            "omega": 0.4,
            "F": 10.0,
        }
    )
    Carnivore.set_params(
        {
            "w_birth": 6.0,
            "sigma_birth": 1.0,
            "beta": 0.75,
            "eta": 0.125,
            "a_half": 40.0,
            "phi_age": 0.3,
            "w_half": 4.0,
            "phi_weight": 0.4,
            "mu": 0.4,
            "gamma": 0.8,
            "zeta": 3.5,
            "xi": 1.1,
            "omega": 0.8,
            "F": 50.0,
            "DeltaPhiMax": 10.0,
        }
    )
def test_eat_carnivore() -> None:
    c = Carnivore()
    h = Herbivore()
    c.set_params({'DeltaPhiMax': 0})
    c.p_eat(c.get_fitness(), h.get_fitness(), c.params['DeltaPhiMax'])