





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  (      lowerCamelCase   ):  # 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"

   a__	:						Union[str, Any]      		=  [1, 2, 3]
   with pytest.raises(lowerCamelCase_   ):
      with parallel_backend("unsupported backend"   ):
         map_nested(lowerCamelCase_							, lowerCamelCase_							, num_proc=2   )

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






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize("num_proc"							, [2, -1]   )
def       _A  (      lowerCamelCase   ):
   a__	:						str      		=  [1, 2]
   a__	:						Optional[int]      		=  {"a": 1, "b": 2}
   a__	:						int      		=  {"a": [1, 2], "b": [3, 4]}
   a__	:						Optional[int]      		=  {"a": {"1": 1}, "b": 2}
   a__	:						Any      		=  {"a": 1, "b": 2, "c": 3, "d": 4}
   a__	:						Tuple      		=  [2, 3]
   a__	:						List[Any]      		=  {"a": 2, "b": 3}
   a__	:						int      		=  {"a": [2, 3], "b": [4, 5]}
   a__	:						str      		=  {"a": {"1": 2}, "b": 3}
   a__	:						Optional[Any]      		=  {"a": 2, "b": 3, "c": 4, "d": 5}

   with parallel_backend("spark"   ):
      assert map_nested(lowerCamelCase_							, lowerCamelCase_							, num_proc=lowerCamelCase_   ) == expected_map_nested_sa
      assert map_nested(lowerCamelCase_							, lowerCamelCase_							, num_proc=lowerCamelCase_   ) == expected_map_nested_sa
      assert map_nested(lowerCamelCase_							, lowerCamelCase_							, num_proc=lowerCamelCase_   ) == expected_map_nested_sa
      assert map_nested(lowerCamelCase_							, lowerCamelCase_							, num_proc=lowerCamelCase_   ) == expected_map_nested_sa
      assert map_nested(lowerCamelCase_							, lowerCamelCase_							, num_proc=lowerCamelCase_   ) == expected_map_nested_sa






SCREAMING_SNAKE_CASE__       :			Union[str, Any]			      =						9.80665






def       _A  (      lowerCamelCase							, lowerCamelCase							, lowerCamelCase = g   ):

   if fluid_density <= 0:
      raise ValueError("Impossible fluid density"   )
   if volume < 0:
      raise ValueError("Impossible Object volume"   )
   if gravity <= 0:
      raise ValueError("Impossible Gravity"   )

   return fluid_density * gravity * volume


if __name__ == "__main__":
  import doctest

  # run doctest
  doctest.testmod()

