'''simple docstring'''

import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict







@pytest.mark.parametrize(
    '''split_dict'''  ,			[
        SplitDict(),
        SplitDict({'''train''': SplitInfo(name='''train'''  ,			num_bytes=13_37  ,			num_examples=42  ,			dataset_name='''my_dataset'''    )}    ),
        SplitDict({'''train''': SplitInfo(name='''train'''  ,			num_bytes=13_37  ,			num_examples=42    )}    ),
        SplitDict({'''train''': SplitInfo()}    ),
    ]  ,			)
def __UpperCamelCase(   _A					:				SplitDict    ):
   '''simple docstring'''
   UpperCAmelCase__							:				int   				=  split_dict._to_yaml_list()
   assert len(_A    ) == len(_A    )
   UpperCAmelCase__							:				Dict   				=  SplitDict._from_yaml_list(_A    )
   for split_name, split_info in split_dict.items():
      # dataset_name field is deprecated, and is therefore not part of the YAML dump
      UpperCAmelCase__							:				Optional[Any]   				=  None
      # the split name of split_dict takes over the name of the split info object
      UpperCAmelCase__							:				int   				=  split_name
   assert split_dict == reloaded







@pytest.mark.parametrize(
    '''split_info'''  ,			[SplitInfo(), SplitInfo(dataset_name=_A    ), SplitInfo(dataset_name='''my_dataset'''    )]    )
def __UpperCamelCase(   _A					:				Any    ):
   '''simple docstring'''
   UpperCAmelCase__							:				Optional[int]   				=  asdict(SplitDict({'''train''': split_info}    )    )
   assert "dataset_name" in split_dict_asdict["train"]
   assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name





'''simple docstring'''

from __future__ import annotations

import sys
from collections import deque
from typing import Generic, TypeVar

UpperCamelCase__     :	Tuple				=			TypeVar('T')


class 				_lowercase	(      Generic[T]   ):
      '''simple docstring'''


      UpperCAmelCase_      :      deque[T]  # Cache store of keys
      UpperCAmelCase_      :      set[T]  # References of the keys in cache
      UpperCAmelCase_      :      int      							=   10  # Maximum capacity of cache




      def __init__(				self					,lowerCamelCase_							)			->			None:



         '''simple docstring'''



         UpperCAmelCase__							:				Any   				=  deque()
         UpperCAmelCase__							:				Optional[int]   				=  set()
         if not n:
            UpperCAmelCase__							:				List[Any]   				=  sys.maxsize
         elif n < 0:
            raise ValueError('''n should be an integer greater than 0.'''							)
         else:
            UpperCAmelCase__							:				Any   				=  n




      def 		lowerCAmelCase__					(				self					,lowerCamelCase_							)			->			None:



         '''simple docstring'''



         if x not in self.key_reference:
            if len(self.dq_store							) == LRUCache._MAX_CAPACITY:
               UpperCAmelCase__							:				int   				=  self.dq_store.pop()
               self.key_reference.remove(lowerCamelCase_							)
         else:
            self.dq_store.remove(lowerCamelCase_							)

         self.dq_store.appendleft(lowerCamelCase_							)
         self.key_reference.add(lowerCamelCase_							)




      def 		lowerCAmelCase__					(				self							)			->			None:



         '''simple docstring'''



         for k in self.dq_store:
            print(lowerCamelCase_							)




      def __repr__(				self							)			->			str:



         '''simple docstring'''



         return f'''LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store							)}'''


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  UpperCamelCase__     :	LRUCache[str | int]				=			LRUCache(4)
  lru_cache.refer('A')
  lru_cache.refer(2)
  lru_cache.refer(3)
  lru_cache.refer('A')
  lru_cache.refer(4)
  lru_cache.refer(5)
  lru_cache.display()

  print(lru_cache)
  assert str(lru_cache) == "LRUCache(4) => [5, 4, 'A', 3]"




