# Path: lcs/Perception.py
# class Perception(collections.abc.Sequence):
#     """
#     Represents current state of the environment at given time instance.
#     By default each environment attribute is represented as `str` type.
#     """
# 
#     __slots__ = ['_items', 'oktypes']
# 
#     def __init__(self, observation, oktypes=(str,)):
#         assert all(type(e) in oktypes for e in observation)
#         self._items = tuple(observation)
# 
#     @classmethod
#     def empty(cls):
#         return cls([], oktypes=(None,))
# 
#     def __hash__(self):
#         return hash(self._items)
# 
#     def __getitem__(self, i):
#         return self._items[i]
# 
#     def __len__(self) -> int:
#         return len(self._items)
# 
#     def __repr__(self):
#         return ' '.join(map(str, self))
# 
#     def __eq__(self, other):
#         return all(p0 == p1 for p0, p1 in zip(self, other))
# 
# Path: lcs/agents/xcs/Condition.py
# class Condition(ImmutableSequence):
# 
#     def subsumes(self, other) -> bool:
#         for ci, oi in zip(self, other):
#             if ci != self.WILDCARD and oi != self.WILDCARD and ci != oi:
#                 return False
#         return True
# 
#     @property
#     def wildcard_number(self) -> int:
#         return sum(1 for c in self if c == self.WILDCARD)
# 
#     def is_more_general(self, other: Condition) -> bool:
#         for ci, oi in zip(self, other):
#             if ci != self.WILDCARD and ci != oi:
#                 return False
#         return True


import pytest
from lcs import Perception
from lcs.agents.xcs.Condition import Condition
    @pytest.mark.parametrize("cond1, cond2, result", [
        ("1111", "1111", True),
        ("11##", "1111", True),
        ("11##", "11##", True),
        ("11", "1111", True),
        ("1111", "10##", False),
    ])
    def test_subsumes(self, cond1, cond2, result):
        assert result == Condition(cond1).subsumes(Perception(cond2))
        assert result == Condition(cond1).subsumes(Condition(cond2))
        assert result == Condition(cond1).subsumes(Perception(cond2))
        assert result == Condition(cond1).subsumes(cond2)

    @pytest.mark.parametrize("cond, num", [
        ("1011", 0),
        ("101#", 1),
        ("1##1", 2),
        ("##1#", 3),
    ])
    def test_number_of_wildcards(self, cond, num):
        assert Condition(cond).wildcard_number == num

    @pytest.mark.parametrize("cond1, cond2, result", [
        ("1111", "1111", True),
        ("11##", "1111", True),
        ("####", "11##", True),
        ("1100", "####", False),
        ("1111", "10##", False),
    ])
    def test_is_more_general(self, cond1, cond2, result):

# Path: lcs/Perception.py
# class Perception(collections.abc.Sequence):
#     """
#     Represents current state of the environment at given time instance.
#     By default each environment attribute is represented as `str` type.
#     """
# 
#     __slots__ = ['_items', 'oktypes']
# 
#     def __init__(self, observation, oktypes=(str,)):
#         assert all(type(e) in oktypes for e in observation)
#         self._items = tuple(observation)
# 
#     @classmethod
#     def empty(cls):
#         return cls([], oktypes=(None,))
# 
#     def __hash__(self):
#         return hash(self._items)
# 
#     def __getitem__(self, i):
#         return self._items[i]
# 
#     def __len__(self) -> int:
#         return len(self._items)
# 
#     def __repr__(self):
#         return ' '.join(map(str, self))
# 
#     def __eq__(self, other):
#         return all(p0 == p1 for p0, p1 in zip(self, other))
# 
# Path: lcs/agents/xcs/Condition.py
# class Condition(ImmutableSequence):
# 
#     def subsumes(self, other) -> bool:
#         for ci, oi in zip(self, other):
#             if ci != self.WILDCARD and oi != self.WILDCARD and ci != oi:
#                 return False
#         return True
# 
#     @property
#     def wildcard_number(self) -> int:
#         return sum(1 for c in self if c == self.WILDCARD)
# 
#     def is_more_general(self, other: Condition) -> bool:
#         for ci, oi in zip(self, other):
#             if ci != self.WILDCARD and ci != oi:
#                 return False
#         return True


# Path: tests/lcs/agents/xcs/test_Condition.py
import pytest
from lcs import Perception
from lcs.agents.xcs.Condition import Condition

    @pytest.mark.parametrize("cond1, cond2, result", [
        ("1111", "1111", True),
        ("11##", "1111", True),
        ("11##", "11##", True),
        ("11", "1111", True),
        ("1111", "10##", False),
    ])
    def test_subsumes(self, cond1, cond2, result):
        assert result == Condition(cond1).subsumes(Perception(cond2))
        assert result == Condition(cond1).subsumes(Condition(cond2))
        assert result == Condition(cond1).subsumes(Perception(cond2))
        assert result == Condition(cond1).subsumes(cond2)

    @pytest.mark.parametrize("cond, num", [
        ("1011", 0),
        ("101#", 1),
        ("1##1", 2),
        ("##1#", 3),
    ])
    def test_number_of_wildcards(self, cond, num):
        assert Condition(cond).wildcard_number == num

    @pytest.mark.parametrize("cond1, cond2, result", [
        ("1111", "1111", True),
        ("11##", "1111", True),
        ("####", "11##", True),
        ("1100", "####", False),
        ("1111", "10##", False),
    ])
    def test_is_more_general(self, cond1, cond2, result):

        assert Condition(cond1).is_more_general(Condition(cond2)) == result