





'''simple docstring'''

import textwrap

import pyarrow as pa
import pytest

from datasets import Features, Value
from datasets.packaged_modules.json.json import Json


@pytest.fixture
def 		__UpperCamelCase		(       _UpperCAmelCase   ):
		__UpperCAmelCase     :				str					   =			tmp_path / "file.jsonl"
		__UpperCAmelCase     :				Optional[int]					   =			textwrap.dedent(
		    "\\n        {\"col_1\": -1}\n        {\"col_1\": 1, \"col_2\": 2}\n        {\"col_1\": 10, \"col_2\": 20}\n        "   )
		with open(_UpperCamelCase,    "w"   ) as f:
				f.write(_UpperCamelCase   )
		return str(_UpperCamelCase   )


@pytest.fixture
def 		__UpperCamelCase		(       _UpperCAmelCase   ):
		__UpperCAmelCase     :				str					   =			tmp_path / "file_utf16_encoded.jsonl"
		__UpperCAmelCase     :				int					   =			textwrap.dedent(
		    "\\n        {\"col_1\": -1}\n        {\"col_1\": 1, \"col_2\": 2}\n        {\"col_1\": 10, \"col_2\": 20}\n        "   )
		with open(_UpperCamelCase,    "w",    encoding="utf-16"   ) as f:
				f.write(_UpperCamelCase   )
		return str(_UpperCamelCase   )


@pytest.fixture
def 		__UpperCamelCase		(       _UpperCAmelCase   ):
		__UpperCAmelCase     :				Optional[Any]					   =			tmp_path / "file_with_list_of_dicts.json"
		__UpperCAmelCase     :				Optional[int]					   =			textwrap.dedent(
		    "\\n        [\n            {\"col_1\": -1},\n            {\"col_1\": 1, \"col_2\": 2},\n            {\"col_1\": 10, \"col_2\": 20}\n        ]\n        "   )
		with open(_UpperCamelCase,    "w"   ) as f:
				f.write(_UpperCamelCase   )
		return str(_UpperCamelCase   )


@pytest.fixture
def 		__UpperCamelCase		(       _UpperCAmelCase   ):
		__UpperCAmelCase     :				int					   =			tmp_path / "file_with_list_of_dicts_field.json"
		__UpperCAmelCase     :				int					   =			textwrap.dedent(
		    "\\n        {\n            \"field1\": 1,\n            \"field2\": \"aabb\",\n            \"field3\": [\n                {\"col_1\": -1},\n                {\"col_1\": 1, \"col_2\": 2},\n                {\"col_1\": 10, \"col_2\": 20}\n            ]\n        }\n        "   )
		with open(_UpperCamelCase,    "w"   ) as f:
				f.write(_UpperCamelCase   )
		return str(_UpperCamelCase   )


@pytest.mark.parametrize(
    "file_fixture, config_kwargs",    [
        ("jsonl_file", {}),
        ("jsonl_file_utf16_encoded", {"encoding": "utf-16"}),
        ("json_file_with_list_of_dicts", {}),
        ("json_file_with_list_of_dicts_field", {"field": "field3"}),
    ],    )
def 		__UpperCamelCase		(       _UpperCAmelCase,    _UpperCAmelCase,    _UpperCAmelCase   ):
		__UpperCAmelCase     :				str					   =			Json(**_UpperCamelCase   )
		__UpperCAmelCase     :				Any					   =			json._generate_tables([[request.getfixturevalue(_UpperCamelCase   )]]   )
		__UpperCAmelCase     :				List[Any]					   =			pa.concat_tables([table for _, table in generator]   )
		assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20]}






@pytest.mark.parametrize(
    "file_fixture, config_kwargs",    [
        (
            "jsonl_file",
            {"features": Features({"col_1": Value("int64"   ), "col_2": Value("int64"   ), "missing_col": Value("string"   )}   )},
        ),
        (
            "json_file_with_list_of_dicts",
            {"features": Features({"col_1": Value("int64"   ), "col_2": Value("int64"   ), "missing_col": Value("string"   )}   )},
        ),
        (
            "json_file_with_list_of_dicts_field",
            {
                "field": "field3",
                "features": Features(
                    {"col_1": Value("int64"   ), "col_2": Value("int64"   ), "missing_col": Value("string"   )}   ),
            },
        ),
    ],    )
def 		__UpperCamelCase		(       _UpperCAmelCase,    _UpperCAmelCase,    _UpperCAmelCase   ):
		__UpperCAmelCase     :				Any					   =			Json(**_UpperCamelCase   )
		__UpperCAmelCase     :				Optional[Any]					   =			json._generate_tables([[request.getfixturevalue(_UpperCamelCase   )]]   )
		__UpperCAmelCase     :				List[Any]					   =			pa.concat_tables([table for _, table in generator]   )
		assert pa_table.to_pydict() == {"col_1": [-1, 1, 10], "col_2": [None, 2, 20], "missing_col": [None, None, None]}





'''simple docstring'''




from scipy.constants import g





def      _UpperCAmelCase    (							_UpperCamelCase    :	float,   _UpperCamelCase    :	float   )	->      float:
    if mass < 0:
        # handling of negative values of mass
        raise ValueError('''The mass of a body cannot be negative'''   )
    if height < 0:
        # handling of negative values of height
        raise ValueError('''The height above the ground cannot be negative'''   )
    return mass * g * height


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

  testmod(name='potential_energy')






