






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 							lowerCamelCase__ (       __lowerCamelCase     :	Any						):  # picklable for multiprocessing
  return i + 1






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

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






'''simple docstring'''






import math







def 							UpperCamelCase_     (       A__   :  float				,       A__   :  float   ):
  '''simple docstring'''





  if initial_intensity < 0:
    raise ValueError("""The value of intensity cannot be negative"""   )
    # handling of negative values of initial intensity
  if angle < 0 or angle > 3_60:
    raise ValueError("""In Malus Law, the angle is in the range 0-360 degrees"""   )
    # handling of values out of allowed range
  return initial_intensity * (math.cos(math.radians(A__   )   ) ** 2)


if __name__ == "__main__":
  import doctest

  doctest.testmod(name="malus_law")



