



"""simple docstring"""






__snake_case							:   int      =    {
    '''meter''': '''m''',
    '''kilometer''': '''km''',
    '''megametre''': '''Mm''',
    '''gigametre''': '''Gm''',
    '''terametre''': '''Tm''',
    '''petametre''': '''Pm''',
    '''exametre''': '''Em''',
    '''zettametre''': '''Zm''',
    '''yottametre''': '''Ym''',
}
# Exponent of the factor(meter)
__snake_case							:   List[Any]      =    {
    '''m''': 0,
    '''km''': 3,
    '''Mm''': 6,
    '''Gm''': 9,
    '''Tm''': 12,
    '''Pm''': 15,
    '''Em''': 18,
    '''Zm''': 21,
    '''Ym''': 24,
}


def 			_lowercase				(  __snake_case					,__snake_case					,__snake_case	)						->   float:
			__lowerCAmelCase      :  List[Any]												=       from_type.lower().strip("s"	)
			__lowerCAmelCase      :  int												=       to_type.lower().strip("s"	)

			__lowerCAmelCase      :  str												=       UNIT_SYMBOL.get(__lowercase					,__lowercase	)
			__lowerCAmelCase      :  List[Any]												=       UNIT_SYMBOL.get(__lowercase					,__lowercase	)

			if from_sanitized not in METRIC_CONVERSION:
						__lowerCAmelCase      :  List[str]												=       (
						    F"""Invalid \'from_type\' value: {from_type!r}.\n"""
						    F"""Conversion abbreviations are: {', '.join(__lowercase	)}"""
						)
						raise ValueError(__lowercase	)
			if to_sanitized not in METRIC_CONVERSION:
						__lowerCAmelCase      :  int												=       (
						    F"""Invalid \'to_type\' value: {to_type!r}.\n"""
						    F"""Conversion abbreviations are: {', '.join(__lowercase	)}"""
						)
						raise ValueError(__lowercase	)
			__lowerCAmelCase      :  List[Any]												=       METRIC_CONVERSION[from_sanitized]
			__lowerCAmelCase      :  Dict												=       METRIC_CONVERSION[to_sanitized]
			__lowerCAmelCase      :  Dict												=       1

			if from_exponent > to_exponent:
						__lowerCAmelCase      :  int												=       from_exponent - to_exponent
			else:
						__lowerCAmelCase      :  Optional[int]												=       -(to_exponent - from_exponent)

			return value * pow(10					,__lowercase	)


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

	testmod()






'''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(__lowercase			,     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 	UpperCAmelCase_							(					__lowercase							:      int			,     __lowercase							:      Dict       )		->       List[Any]:


     '''simple docstring'''



     _UpperCAmelCase     							=   _distribute_shards(**__lowercase       )
     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 	UpperCAmelCase_							(					__lowercase							:      Dict			,     __lowercase							:      Optional[Any]			,     __lowercase							:      int       )		->       str:


     '''simple docstring'''



     _UpperCAmelCase     							=   _split_gen_kwargs(__lowercase			,     __lowercase       )
     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 	UpperCAmelCase_							(					__lowercase							:      Optional[Any]			,     __lowercase							:      List[Any]       )		->       List[Any]:


     '''simple docstring'''



     if expected is RuntimeError:
          with pytest.raises(__lowercase       ):
               _number_of_shards_in_gen_kwargs(__lowercase       )
     else:
          _UpperCAmelCase     							=   _number_of_shards_in_gen_kwargs(__lowercase       )
          assert out == expected




