






"""simple docstring"""
import io
import json

import fsspec
import pytest

from datasets import Dataset, DatasetDict, Features, NamedSplit, Value
from datasets.io.json import JsonDatasetReader, JsonDatasetWriter

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases

def        snake_case   (     A__			,A__		):
			assert isinstance(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)
			assert dataset.num_rows == 4
			assert dataset.num_columns == 3
			assert dataset.column_names == ["col_1", "col_2", "col_3"]
			for feature, expected_dtype in expected_features.items():
						assert dataset.features[feature].dtype == expected_dtype

@pytest.mark.parametrize("keep_in_memory"			,[False, True]		)
def        snake_case   (     A__			,A__			,A__		):
			UpperCAmelCase_  :				List[str]      =      tmp_path / "cache"
			UpperCAmelCase_  :				Any      =      {"col_1": "string", "col_2": "int64", "col_3": "float64"}
			with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
						UpperCAmelCase_  :				Dict      =      JsonDatasetReader(_SCREAMING_SNAKE_CASE			,cache_dir=_SCREAMING_SNAKE_CASE			,keep_in_memory=_SCREAMING_SNAKE_CASE		).read()
			_check_json_dataset(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)

@pytest.mark.parametrize(
    "features"			,[
        None,
        {"col_1": "string", "col_2": "int64", "col_3": "float64"},
        {"col_1": "string", "col_2": "string", "col_3": "string"},
        {"col_1": "int32", "col_2": "int32", "col_3": "int32"},
        {"col_1": "float32", "col_2": "float32", "col_3": "float32"},
    ]			,)
def        snake_case   (     A__			,A__			,A__		):
			UpperCAmelCase_  :				List[str]      =      tmp_path / "cache"
			UpperCAmelCase_  :				Union[str, Any]      =      {"col_1": "string", "col_2": "int64", "col_3": "float64"}
			UpperCAmelCase_  :				str      =      features.copy() if features else default_expected_features
			UpperCAmelCase_  :				List[Any]      =      (
			    Features({feature: Value(_SCREAMING_SNAKE_CASE		) for feature, dtype in features.items()}		) if features is not None else None
			)
			UpperCAmelCase_  :				Optional[int]      =      JsonDatasetReader(_SCREAMING_SNAKE_CASE			,features=_SCREAMING_SNAKE_CASE			,cache_dir=_SCREAMING_SNAKE_CASE		).read()
			_check_json_dataset(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)

@pytest.mark.parametrize(
    "features"			,[
        None,
        {"col_3": "float64", "col_1": "string", "col_2": "int64"},
    ]			,)
def        snake_case   (     A__			,A__			,A__		):
			UpperCAmelCase_  :				Optional[int]      =      tmp_path / "cache"
			UpperCAmelCase_  :				int      =      {"col_3": "float64", "col_1": "string", "col_2": "int64"}
			UpperCAmelCase_  :				int      =      features.copy() if features else default_expected_features
			UpperCAmelCase_  :				List[Any]      =      (
			    Features({feature: Value(_SCREAMING_SNAKE_CASE		) for feature, dtype in features.items()}		) if features is not None else None
			)
			UpperCAmelCase_  :				str      =      JsonDatasetReader(_SCREAMING_SNAKE_CASE			,features=_SCREAMING_SNAKE_CASE			,cache_dir=_SCREAMING_SNAKE_CASE		).read()
			assert isinstance(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)
			assert dataset.num_rows == 2
			assert dataset.num_columns == 3
			assert dataset.column_names == ["col_3", "col_1", "col_2"]
			for feature, expected_dtype in expected_features.items():
						assert dataset.features[feature].dtype == expected_dtype

def        snake_case   (     A__			,A__		):
			UpperCAmelCase_  :				List[str]      =      {"col_2": "int64", "col_3": "float64", "col_1": "string"}
			UpperCAmelCase_  :				str      =      features.copy()
			UpperCAmelCase_  :				Union[str, Any]      =      (
			    Features({feature: Value(_SCREAMING_SNAKE_CASE		) for feature, dtype in features.items()}		) if features is not None else None
			)
			UpperCAmelCase_  :				Any      =      tmp_path / "cache"
			UpperCAmelCase_  :				int      =      JsonDatasetReader(_SCREAMING_SNAKE_CASE			,features=_SCREAMING_SNAKE_CASE			,cache_dir=_SCREAMING_SNAKE_CASE		).read()
			assert isinstance(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)
			assert dataset.num_rows == 2
			assert dataset.num_columns == 3
			assert dataset.column_names == ["col_2", "col_3", "col_1"]
			for feature, expected_dtype in expected_features.items():
						assert dataset.features[feature].dtype == expected_dtype

@pytest.mark.parametrize("split"			,[None, NamedSplit("train"		), "train", "test"]		)
def        snake_case   (     A__			,A__			,A__		):
			UpperCAmelCase_  :				str      =      tmp_path / "cache"
			UpperCAmelCase_  :				Optional[int]      =      {"col_1": "string", "col_2": "int64", "col_3": "float64"}
			UpperCAmelCase_  :				List[Any]      =      JsonDatasetReader(_SCREAMING_SNAKE_CASE			,cache_dir=_SCREAMING_SNAKE_CASE			,split=_SCREAMING_SNAKE_CASE		).read()
			_check_json_dataset(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)
			assert dataset.split == split if split else "train"

@pytest.mark.parametrize("path_type"			,[str, list]		)
def        snake_case   (     A__			,A__			,A__		):



			if issubclass(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		):
						UpperCAmelCase_  :				Tuple      =      jsonl_path
			elif issubclass(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		):
						UpperCAmelCase_  :				Dict      =      [jsonl_path]
			UpperCAmelCase_  :				Any      =      tmp_path / "cache"
			UpperCAmelCase_  :				int      =      {"col_1": "string", "col_2": "int64", "col_3": "float64"}
			UpperCAmelCase_  :				List[str]      =      JsonDatasetReader(_SCREAMING_SNAKE_CASE			,cache_dir=_SCREAMING_SNAKE_CASE		).read()
			_check_json_dataset(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)

def        snake_case   (     A__			,A__			,A__=("train",)		):
			assert isinstance(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)
			for split in splits:
						UpperCAmelCase_  :				Dict      =      dataset_dict[split]
						assert dataset.num_rows == 4
						assert dataset.num_columns == 3
						assert dataset.column_names == ["col_1", "col_2", "col_3"]
						for feature, expected_dtype in expected_features.items():
									assert dataset.features[feature].dtype == expected_dtype

@pytest.mark.parametrize("keep_in_memory"			,[False, True]		)
def        snake_case   (     A__			,A__			,A__		):
			UpperCAmelCase_  :				Union[str, Any]      =      tmp_path / "cache"
			UpperCAmelCase_  :				str      =      {"col_1": "string", "col_2": "int64", "col_3": "float64"}
			with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
						UpperCAmelCase_  :				List[str]      =      JsonDatasetReader({"train": jsonl_path}			,cache_dir=_SCREAMING_SNAKE_CASE			,keep_in_memory=_SCREAMING_SNAKE_CASE		).read()
			_check_json_datasetdict(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)

@pytest.mark.parametrize(
    "features"			,[
        None,
        {"col_1": "string", "col_2": "int64", "col_3": "float64"},
        {"col_1": "string", "col_2": "string", "col_3": "string"},
        {"col_1": "int32", "col_2": "int32", "col_3": "int32"},
        {"col_1": "float32", "col_2": "float32", "col_3": "float32"},
    ]			,)
def        snake_case   (     A__			,A__			,A__		):
			UpperCAmelCase_  :				Optional[int]      =      tmp_path / "cache"
			UpperCAmelCase_  :				Optional[int]      =      {"col_1": "string", "col_2": "int64", "col_3": "float64"}
			UpperCAmelCase_  :				Dict      =      features.copy() if features else default_expected_features
			UpperCAmelCase_  :				str      =      (
			    Features({feature: Value(_SCREAMING_SNAKE_CASE		) for feature, dtype in features.items()}		) if features is not None else None
			)
			UpperCAmelCase_  :				List[str]      =      JsonDatasetReader({"train": jsonl_path}			,features=_SCREAMING_SNAKE_CASE			,cache_dir=_SCREAMING_SNAKE_CASE		).read()
			_check_json_datasetdict(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE		)

@pytest.mark.parametrize("split"			,[None, NamedSplit("train"		), "train", "test"]		)
def        snake_case   (     A__			,A__			,A__		):



			if split:
						UpperCAmelCase_  :				int      =      {split: jsonl_path}
			else:
						UpperCAmelCase_  :				Any      =      "train"
						UpperCAmelCase_  :				Optional[int]      =      {"train": jsonl_path, "test": jsonl_path}
			UpperCAmelCase_  :				Optional[int]      =      tmp_path / "cache"
			UpperCAmelCase_  :				Optional[int]      =      {"col_1": "string", "col_2": "int64", "col_3": "float64"}
			UpperCAmelCase_  :				Union[str, Any]      =      JsonDatasetReader(_SCREAMING_SNAKE_CASE			,cache_dir=_SCREAMING_SNAKE_CASE		).read()
			_check_json_datasetdict(_SCREAMING_SNAKE_CASE			,_SCREAMING_SNAKE_CASE			,splits=list(path.keys()		)		)
			assert all(dataset[split].split == split for split in path.keys()		)

def        snake_case   (     A__		):
			return json.load(_SCREAMING_SNAKE_CASE		)

def        snake_case   (     A__		):
			return [json.loads(_SCREAMING_SNAKE_CASE		) for line in buffer]







class     UpperCamelCase_ :





	@pytest.mark.parametrize("lines, load_json_function"			,			[(True, load_json_lines), (False, load_json)]		)
	def   _SCREAMING_SNAKE_CASE   (   self      :				Dict			,			lowerCAmelCase_      :				List[str]			,			lowerCAmelCase_      :				int			,			lowerCAmelCase_      :				Union[str, Any]		)		->    Optional[Any]:
				with io.BytesIO() as buffer:
							JsonDatasetWriter(__UpperCamelCase			,			__UpperCamelCase			,			lines=__UpperCamelCase		).write()
							buffer.seek(0		)
							UpperCAmelCase_  :				Union[str, Any]      =      load_json_function(__UpperCamelCase		)
				assert isinstance(__UpperCamelCase			,			__UpperCamelCase		)
				assert isinstance(exported_content[0]			,			__UpperCamelCase		)
				assert len(__UpperCamelCase		) == 10





	@pytest.mark.parametrize(
	    "orient, container, keys, len_at"			,			[
	        ("records", list, {"tokens", "labels", "answers", "id"}, None),
	        ("split", dict, {"columns", "data"}, "data"),
	        ("index", dict, set("0123456789"		), None),
	        ("columns", dict, {"tokens", "labels", "answers", "id"}, "tokens"),
	        ("values", list, None, None),
	        ("table", dict, {"schema", "data"}, "data"),
	    ]			,			)
	def   _SCREAMING_SNAKE_CASE   (   self      :				int			,			lowerCAmelCase_      :				Tuple			,			lowerCAmelCase_      :				Dict			,			lowerCAmelCase_      :				Optional[int]			,			lowerCAmelCase_      :				Any			,			lowerCAmelCase_      :				List[str]		)		->    List[str]:
				with io.BytesIO() as buffer:
							JsonDatasetWriter(__UpperCamelCase			,			__UpperCamelCase			,			lines=__UpperCamelCase			,			orient=__UpperCamelCase		).write()
							buffer.seek(0		)
							UpperCAmelCase_  :				List[Any]      =      load_json(__UpperCamelCase		)
				assert isinstance(__UpperCamelCase			,			__UpperCamelCase		)
				if keys:
							if container is dict:
										assert exported_content.keys() == keys
							else:
										assert exported_content[0].keys() == keys
				else:
							assert not hasattr(__UpperCamelCase			,			"keys"		) and not hasattr(exported_content[0]			,			"keys"		)
				if len_at:
							assert len(exported_content[len_at]		) == 10
				else:
							assert len(__UpperCamelCase		) == 10





	@pytest.mark.parametrize("lines, load_json_function"			,			[(True, load_json_lines), (False, load_json)]		)
	def   _SCREAMING_SNAKE_CASE   (   self      :				int			,			lowerCAmelCase_      :				List[Any]			,			lowerCAmelCase_      :				int			,			lowerCAmelCase_      :				int		)		->    Any:
				with io.BytesIO() as buffer:
							JsonDatasetWriter(__UpperCamelCase			,			__UpperCamelCase			,			lines=__UpperCamelCase			,			num_proc=2		).write()
							buffer.seek(0		)
							UpperCAmelCase_  :				str      =      load_json_function(__UpperCamelCase		)
				assert isinstance(__UpperCamelCase			,			__UpperCamelCase		)
				assert isinstance(exported_content[0]			,			__UpperCamelCase		)
				assert len(__UpperCamelCase		) == 10





	@pytest.mark.parametrize(
	    "orient, container, keys, len_at"			,			[
	        ("records", list, {"tokens", "labels", "answers", "id"}, None),
	        ("split", dict, {"columns", "data"}, "data"),
	        ("index", dict, set("0123456789"		), None),
	        ("columns", dict, {"tokens", "labels", "answers", "id"}, "tokens"),
	        ("values", list, None, None),
	        ("table", dict, {"schema", "data"}, "data"),
	    ]			,			)
	def   _SCREAMING_SNAKE_CASE   (   self      :				Optional[int]			,			lowerCAmelCase_      :				List[Any]			,			lowerCAmelCase_      :				int			,			lowerCAmelCase_      :				Dict			,			lowerCAmelCase_      :				Optional[Any]			,			lowerCAmelCase_      :				Any		)		->    int:
				with io.BytesIO() as buffer:
							JsonDatasetWriter(__UpperCamelCase			,			__UpperCamelCase			,			lines=__UpperCamelCase			,			orient=__UpperCamelCase			,			num_proc=2		).write()
							buffer.seek(0		)
							UpperCAmelCase_  :				Any      =      load_json(__UpperCamelCase		)
				assert isinstance(__UpperCamelCase			,			__UpperCamelCase		)
				if keys:
							if container is dict:
										assert exported_content.keys() == keys
							else:
										assert exported_content[0].keys() == keys
				else:
							assert not hasattr(__UpperCamelCase			,			"keys"		) and not hasattr(exported_content[0]			,			"keys"		)
				if len_at:
							assert len(exported_content[len_at]		) == 10
				else:
							assert len(__UpperCamelCase		) == 10





	def   _SCREAMING_SNAKE_CASE   (   self      :				Optional[Any]			,			lowerCAmelCase_      :				Any		)		->    Optional[int]:
				with pytest.raises(__UpperCamelCase		):
							with io.BytesIO() as buffer:
										JsonDatasetWriter(__UpperCamelCase			,			__UpperCamelCase			,			num_proc=0		)





	@pytest.mark.parametrize("compression, extension"			,			[("gzip", "gz"), ("bz2", "bz2"), ("xz", "xz")]		)
	def   _SCREAMING_SNAKE_CASE   (   self      :				Optional[Any]			,			lowerCAmelCase_      :				List[str]			,			lowerCAmelCase_      :				int			,			lowerCAmelCase_      :				Tuple			,			lowerCAmelCase_      :				int			,			lowerCAmelCase_      :				Union[str, Any]		)		->    str:
				UpperCAmelCase_  :				Union[str, Any]      =      tmp_path_factory.mktemp("data"		) / f"""test.json.{extension}"""
				UpperCAmelCase_  :				Dict      =      str(shared_datadir / f"""test_file.json.{extension}"""		)
				JsonDatasetWriter(__UpperCamelCase			,			__UpperCamelCase			,			compression=__UpperCamelCase		).write()

				with fsspec.open(__UpperCamelCase			,			"rb"			,			compression="infer"		) as f:
							UpperCAmelCase_  :				Dict      =      f.read()
				with fsspec.open(__UpperCamelCase			,			"rb"			,			compression="infer"		) as f:
							UpperCAmelCase_  :				List[Any]      =      f.read()
				assert exported_content == original_content











"""simple docstring"""
from __future__ import annotations

import math

def        snake_case   (     A__		):

			if 1 < number < 4:
						# 2 and 3 are primes
						return True
			elif number < 2 or number % 2 == 0 or number % 3 == 0:
						# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
						return False

			# All primes number are in format of 6k +/- 1
			for i in range(5			,int(math.sqrt(A__		) + 1		)			,6		):
						if number % i == 0 or number % (i + 2) == 0:
									return False
			return True


lowerCamelCase_       			=   [num for num in range(3, 10_0001, 2) if not is_prime(num)]

def        snake_case   (     A__		):
			if not isinstance(A__			,A__		):
						raise ValueError("n must be an integer"		)
			if n <= 0:
						raise ValueError("n must be >= 0"		)

			UpperCAmelCase_  :				List[str]      =      []
			for num in range(len(A__		)		):
						UpperCAmelCase_  :				Dict      =      0
						while 2 * i * i <= odd_composites[num]:
									UpperCAmelCase_  :				List[str]      =      odd_composites[num] - 2 * i * i
									if is_prime(A__		):
												break
									i += 1
						else:
									list_nums.append(odd_composites[num]		)
									if len(A__		) == n:
												return list_nums

			return []

def        snake_case   (     ):
			return compute_nums(1		)[0]


if __name__ == "__main__":
			print(f'{solution() = }')



