# Path: lcs/strategies/action_selection/EpsilonGreedy.py
# class EpsilonGreedy:
# 
#     def __init__(self, all_actions: int, **kwargs):
#         self.all_actions = all_actions
#         self.epsilon = kwargs['epsilon']
#         assert 0 <= self.epsilon <= 1
# 
#     def __call__(self, population) -> int:
#         if np.random.uniform() > self.epsilon:
#             return BestAction(all_actions=self.all_actions)(population)
#         else:
#             return RandomAction(all_actions=self.all_actions)(population)


import pytest
import lcs.agents.acs as acs
import lcs.agents.acs2 as acs2
from lcs.strategies.action_selection import EpsilonGreedy



class TestEpsilonGreedy:

    @pytest.fixture
    def acs_cfg(self):
        return acs.Configuration(
            classifier_length=4,
            number_of_possible_actions=4,
            epsilon=0.5)

    @pytest.fixture
    def acs2_cfg(self):
        return acs2.Configuration(
            classifier_length=4,
            number_of_possible_actions=4,
            epsilon=0.5)

    def test_should_raise_error_when_epsilon_is_missing(self):
        with pytest.raises(KeyError):

# Path: lcs/strategies/action_selection/EpsilonGreedy.py
# class EpsilonGreedy:
# 
#     def __init__(self, all_actions: int, **kwargs):
#         self.all_actions = all_actions
#         self.epsilon = kwargs['epsilon']
#         assert 0 <= self.epsilon <= 1
# 
#     def __call__(self, population) -> int:
#         if np.random.uniform() > self.epsilon:
#             return BestAction(all_actions=self.all_actions)(population)
#         else:
#             return RandomAction(all_actions=self.all_actions)(population)


# Path: tests/lcs/strategies/action_selection/test_EpsilonGreedy.py
import pytest
import lcs.agents.acs as acs
import lcs.agents.acs2 as acs2
from lcs.strategies.action_selection import EpsilonGreedy




class TestEpsilonGreedy:

    @pytest.fixture
    def acs_cfg(self):
        return acs.Configuration(
            classifier_length=4,
            number_of_possible_actions=4,
            epsilon=0.5)

    @pytest.fixture
    def acs2_cfg(self):
        return acs2.Configuration(
            classifier_length=4,
            number_of_possible_actions=4,
            epsilon=0.5)

    def test_should_raise_error_when_epsilon_is_missing(self):
        with pytest.raises(KeyError):

            EpsilonGreedy(4)