


'''simple docstring'''





import pytest

from datasets.parallel import ParallelBackendConfig, parallel_backend
from datasets.utils.py_utils import map_nested

from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows


def        a__     (					UpperCamelCase_						:      Any						):  # picklable for multiprocessing
   return i + 1


@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def        a__     (					):
   with parallel_backend('''spark'''						):
      assert ParallelBackendConfig.backend_name == "spark"

   UpperCAmelCase__	:int      =      [1, 2, 3]
   with pytest.raises(UpperCamelCase_						):
      with parallel_backend('''unsupported backend'''						):
         map_nested(UpperCamelCase_,   UpperCamelCase_,   num_proc=2						)

   with pytest.raises(UpperCamelCase_						):
      with parallel_backend('''unsupported backend'''						):
         map_nested(UpperCamelCase_,   UpperCamelCase_,   num_proc=-1						)


@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize('''num_proc''',   [2, -1]						)
def        a__     (					UpperCamelCase_						:      Any						):
   UpperCAmelCase__	:Optional[int]      =      [1, 2]
   UpperCAmelCase__	:Optional[Any]      =      {'''a''': 1, '''b''': 2}
   UpperCAmelCase__	:Dict      =      {'''a''': [1, 2], '''b''': [3, 4]}
   UpperCAmelCase__	:str      =      {'''a''': {'''1''': 1}, '''b''': 2}
   UpperCAmelCase__	:Optional[int]      =      {'''a''': 1, '''b''': 2, '''c''': 3, '''d''': 4}
   UpperCAmelCase__	:str      =      [2, 3]
   UpperCAmelCase__	:Any      =      {'''a''': 2, '''b''': 3}
   UpperCAmelCase__	:Union[str, Any]      =      {'''a''': [2, 3], '''b''': [4, 5]}
   UpperCAmelCase__	:Any      =      {'''a''': {'''1''': 2}, '''b''': 3}
   UpperCAmelCase__	:Optional[int]      =      {'''a''': 2, '''b''': 3, '''c''': 4, '''d''': 5}

   with parallel_backend('''spark'''						):
      assert map_nested(UpperCamelCase_,   UpperCamelCase_,   num_proc=UpperCamelCase_						) == expected_map_nested_sa
      assert map_nested(UpperCamelCase_,   UpperCamelCase_,   num_proc=UpperCamelCase_						) == expected_map_nested_sa
      assert map_nested(UpperCamelCase_,   UpperCamelCase_,   num_proc=UpperCamelCase_						) == expected_map_nested_sa
      assert map_nested(UpperCamelCase_,   UpperCamelCase_,   num_proc=UpperCamelCase_						) == expected_map_nested_sa
      assert map_nested(UpperCamelCase_,   UpperCamelCase_,   num_proc=UpperCamelCase_						) == expected_map_nested_sa







'''simple docstring'''





def        a__     (					UpperCamelCase_						:      int | float | str						):
   try:
      UpperCAmelCase__	:Union[str, Any]      =      float(UpperCamelCase_						)
   except ValueError:
      raise ValueError('''Please enter a valid number'''						)
   UpperCAmelCase__	:List[str]      =      decimal - int(UpperCamelCase_						)
   if fractional_part == 0:
      return int(UpperCamelCase_						), 1
   else:
      UpperCAmelCase__	:List[Any]      =      len(str(UpperCamelCase_						).split('''.'''						)[1]						)
      UpperCAmelCase__	:Tuple      =      int(decimal * (10**number_of_frac_digits)						)
      UpperCAmelCase__	:int      =      10**number_of_frac_digits
      UpperCAmelCase__   ,						UpperCAmelCase__	:List[str]      =      denominator, numerator
      while True:
         UpperCAmelCase__	:Optional[Any]      =      dividend % divisor
         if remainder == 0:
            break
         UpperCAmelCase__   ,						UpperCAmelCase__	:List[str]      =      divisor, remainder
      UpperCAmelCase__   ,						UpperCAmelCase__	:Tuple      =      numerator / divisor, denominator / divisor
      return int(UpperCamelCase_						), int(UpperCamelCase_						)


if __name__ == "__main__":
    print(F'''{decimal_to_fraction(2) = }''')
    print(F'''{decimal_to_fraction(89.0) = }''')
    print(F'''{decimal_to_fraction("67") = }''')
    print(F'''{decimal_to_fraction("45.0") = }''')
    print(F'''{decimal_to_fraction(1.5) = }''')
    print(F'''{decimal_to_fraction("6.25") = }''')
    print(F'''{decimal_to_fraction("78td") = }''')



