





'''simple docstring'''




import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


__UpperCAmelCase         =   500000

__UpperCAmelCase   ,     __UpperCAmelCase         =   os.path.split(__file__)
__UpperCAmelCase         =   os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))



@get_duration
def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE				:							str						=	dataset.select(range(0	,	len(lowerCamelCase_					)	,	2					)					)



@get_duration
def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	dataset.sort("""numbers"""					)



@get_duration
def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE				:							Any						=	dataset.shuffle()



@get_duration
def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE				:							Optional[Any]						=	dataset.train_test_split(0.1					)



@get_duration
def 						__A						(       lowerCamelCase_	,	lowerCamelCase_=10					):


		"""simple docstring"""



		for shard_id in range(lowerCamelCase_					):
				SCREAMING_SNAKE_CASE				:							List[str]						=	dataset.shard(lowerCamelCase_	,	lowerCamelCase_					)



def 						__A						(       ):


		"""simple docstring"""



		SCREAMING_SNAKE_CASE				:							str						=	{"""num examples""": SPEED_TEST_N_EXAMPLES}
		SCREAMING_SNAKE_CASE				:							Any						=	(select, sort, shuffle, train_test_split, shard)
		with tempfile.TemporaryDirectory() as tmp_dir:
				print("""generating dataset"""					)
				SCREAMING_SNAKE_CASE				:							Optional[int]						=	datasets.Features({"""text""": datasets.Value("""string"""					), """numbers""": datasets.Value("""float32"""					)}					)
				SCREAMING_SNAKE_CASE				:							Optional[Any]						=	generate_example_dataset(
				    os.path.join(lowerCamelCase_	,	"""dataset.arrow"""					)	,	lowerCamelCase_	,	num_examples=lowerCamelCase_					)
				print("""Functions"""					)
				for func in functions:
						print(func.__name__					)
						SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	func(lowerCamelCase_					)

		with open(lowerCamelCase_	,	"""wb"""					) as f:
				f.write(json.dumps(lowerCamelCase_					).encode("""utf-8"""					)					)


if __name__ == "__main__":  # useful to run the profiler
							benchmark_indices_mapping()










'''simple docstring'''




from __future__ import annotations



def 						__A						(       lowerCamelCase_					):


		"""simple docstring"""



		if len(lowerCamelCase_					) == 0:
				raise ValueError("""find_min() arg is an empty sequence"""					)
		SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	nums[0]
		for num in nums:
				SCREAMING_SNAKE_CASE				:							Union[str, Any]						=	min(lowerCamelCase_	,	lowerCamelCase_					)
		return min_num


if __name__ == "__main__":
							import doctest

							doctest.testmod(verbose=True)



