





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	(		SCREAMING_SNAKE_CASE					:       Optional[int]						):  # picklable for multiprocessing





  """simple docstring"""



  return i + 1
@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 					_A	(		):





  """simple docstring"""



  with parallel_backend("spark"						):
    assert ParallelBackendConfig.backend_name == "spark"

  a__     : 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	(		SCREAMING_SNAKE_CASE					:       Dict						):





  """simple docstring"""



  a__     : Tuple  =[1, 2]
  a__     : Dict  ={"""a""": 1, """b""": 2}
  a__     : List[str]  ={"""a""": [1, 2], """b""": [3, 4]}
  a__     : Optional[Any]  ={"""a""": {"""1""": 1}, """b""": 2}
  a__     : Optional[Any]  ={"""a""": 1, """b""": 2, """c""": 3, """d""": 4}
  a__     : List[Any]  =[2, 3]
  a__     : Union[str, Any]  ={"""a""": 2, """b""": 3}
  a__     : str  ={"""a""": [2, 3], """b""": [4, 5]}
  a__     : Tuple  ={"""a""": {"""1""": 2}, """b""": 3}
  a__     : Tuple  ={"""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













from maths.prime_check import is_prime
def 					_A	(		SCREAMING_SNAKE_CASE					:       int						):





  """simple docstring"""



  if not isinstance(SCREAMING_SNAKE_CASE	,	SCREAMING_SNAKE_CASE						):
    a__     : Dict  =f'''Input value of [number={number}] must be an integer'''
    raise TypeError(SCREAMING_SNAKE_CASE						)
  if is_prime(SCREAMING_SNAKE_CASE						) and is_prime(number + 2						):
    return number + 2
  else:
    return -1


if __name__ == "__main__":
     import doctest

     doctest.testmod()






