
'''simple docstring'''







import pytest

from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs
@pytest.mark.parametrize(
    '''kwargs, expected'''      ,      [
        ({'''num_shards''': 0, '''max_num_jobs''': 1}, []),
        ({'''num_shards''': 10, '''max_num_jobs''': 1}, [range(10							)]),
        ({'''num_shards''': 10, '''max_num_jobs''': 10}, [range(__SCREAMING_SNAKE_CASE      ,      i + 1							) for i in range(10							)]),
        ({'''num_shards''': 1, '''max_num_jobs''': 10}, [range(1							)]),
        ({'''num_shards''': 10, '''max_num_jobs''': 3}, [range(0      ,      4							), range(4      ,      7							), range(7      ,      10							)]),
        ({'''num_shards''': 3, '''max_num_jobs''': 10}, [range(0      ,      1							), range(1      ,      2							), range(2      ,      3							)]),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int      ,      __SCREAMING_SNAKE_CASE					: Union[str, Any]							):



						"""simple docstring"""





						lowercase_	:     str													=       _distribute_shards(**__SCREAMING_SNAKE_CASE							)
						assert out == expected
@pytest.mark.parametrize(
    '''gen_kwargs, max_num_jobs, expected'''      ,      [
        ({'''foo''': 0}, 10, [{'''foo''': 0}]),
        ({'''shards''': [0, 1, 2, 3]}, 1, [{'''shards''': [0, 1, 2, 3]}]),
        ({'''shards''': [0, 1, 2, 3]}, 4, [{'''shards''': [0]}, {'''shards''': [1]}, {'''shards''': [2]}, {'''shards''': [3]}]),
        ({'''shards''': [0, 1]}, 4, [{'''shards''': [0]}, {'''shards''': [1]}]),
        ({'''shards''': [0, 1, 2, 3]}, 2, [{'''shards''': [0, 1]}, {'''shards''': [2, 3]}]),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int      ,      __SCREAMING_SNAKE_CASE					: int      ,      __SCREAMING_SNAKE_CASE					: Union[str, Any]							):



						"""simple docstring"""





						lowercase_	:     Dict													=       _split_gen_kwargs(__SCREAMING_SNAKE_CASE      ,      __SCREAMING_SNAKE_CASE							)
						assert out == expected




@pytest.mark.parametrize(
    '''gen_kwargs, expected'''      ,      [
        ({'''foo''': 0}, 1),
        ({'''shards''': [0]}, 1),
        ({'''shards''': [0, 1, 2, 3]}, 4),
        ({'''shards''': [0, 1, 2, 3], '''foo''': 0}, 4),
        ({'''shards''': [0, 1, 2, 3], '''other''': (0, 1)}, 4),
        ({'''shards''': [0, 1, 2, 3], '''shards2''': [0, 1]}, RuntimeError),
    ]      ,      )
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: str      ,      __SCREAMING_SNAKE_CASE					: List[Any]							):



						"""simple docstring"""





						if expected is RuntimeError:
												with pytest.raises(__SCREAMING_SNAKE_CASE							):
																		_number_of_shards_in_gen_kwargs(__SCREAMING_SNAKE_CASE							)
						else:
												lowercase_	:     int													=       _number_of_shards_in_gen_kwargs(__SCREAMING_SNAKE_CASE							)
												assert out == expected





'''simple docstring'''







def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int							):



						"""simple docstring"""





						lowercase_	:     Optional[int]													=       int(__SCREAMING_SNAKE_CASE							)
						if decimal in (0, 1):  # Exit cases for the recursion
												return str(__SCREAMING_SNAKE_CASE							)
						lowercase_						, lowercase_	:     List[str]													=       divmod(__SCREAMING_SNAKE_CASE      ,      2							)
						return binary_recursive(__SCREAMING_SNAKE_CASE							) + str(__SCREAMING_SNAKE_CASE							)
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: str							):



						"""simple docstring"""





						lowercase_	:     str													=       str(__SCREAMING_SNAKE_CASE							).strip()
						if not number:
												raise ValueError('''No input value was provided'''							)
						lowercase_	:     Optional[int]													=       '''-''' if number.startswith('''-'''							) else ''''''
						lowercase_	:     Union[str, Any]													=       number.lstrip('''-'''							)
						if not number.isnumeric():
												raise ValueError('''Input value is not an integer'''							)
						return F'''{negative}0b{binary_recursive(int(__SCREAMING_SNAKE_CASE							)							)}'''


if __name__ == "__main__":
							from doctest import testmod

							testmod()



