






"""simple docstring"""



import json
import os
import tempfile

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features import ArrayaD
from utils import generate_examples, get_duration


_snake_case       :      Any       =					(30, 487)
_snake_case       :      List[Any]       =					(36, 1_024)
_snake_case       :      Optional[Any]       =					(100, 100)
_snake_case       :      str       =					100

_snake_case       :      Tuple       =					datasets.Features(
    {"text": ArrayaD(SHAPE_TEST_1, dtype="float32"), "image": ArrayaD(SHAPE_TEST_2, dtype="float32")}
)

_snake_case       :      int       =					os.path.split(__file__)
_snake_case       :      Dict       =					os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py", ".json"))




@get_duration
def 						lowerCamelCase_				(  __A  :		Tuple			,	__A  :		Any			,	__A  :		Optional[Any]			):
     with ArrowWriter(features=__A			,	path=os.path.join(__A			,	'beta.arrow'			)			) as writer:
          for key, record in dummy_data:
               lowerCamelCase__				=my_features.encode_example(__A			)
               writer.write(__A			)
          lowerCamelCase__				,     lowerCamelCase__				=writer.finalize()




@get_duration
def 						lowerCamelCase_				(  __A  :		str			,	__A  :		Optional[int]			):
     lowerCamelCase__				=datasets.Dataset.from_file(
         filename=os.path.join(__A			,	'beta.arrow'			)			,	info=datasets.DatasetInfo(features=__A			)			)
     for _ in dataset:
          pass




@get_duration
def 						lowerCamelCase_				(  __A  :		Any			,	__A  :		Tuple			):
     lowerCamelCase__				=datasets.Dataset.from_file(
         filename=os.path.join(__A			,	'beta.arrow'			)			,	info=datasets.DatasetInfo(features=__A			)			)
     dataset.set_format('numpy'			)
     for _ in dataset:
          pass




@get_duration
def 						lowerCamelCase_				(  __A  :		Dict			,	__A  :		Optional[int]			):
     lowerCamelCase__				=10
     lowerCamelCase__				=datasets.Dataset.from_file(
         filename=os.path.join(__A			,	'beta.arrow'			)			,	info=datasets.DatasetInfo(features=__A			)			)
     for i in range(0			,	len(__A			)			,	__A			):
          lowerCamelCase__				=dataset[i : i + batch_size]




@get_duration
def 						lowerCamelCase_				(  __A  :		List[Any]			,	__A  :		Optional[int]			):
     lowerCamelCase__				=10
     lowerCamelCase__				=datasets.Dataset.from_file(
         filename=os.path.join(__A			,	'beta.arrow'			)			,	info=datasets.DatasetInfo(features=__A			)			)
     dataset.set_format('numpy'			)
     for i in range(0			,	len(__A			)			,	__A			):
          lowerCamelCase__				=dataset[i : i + batch_size]




@get_duration
def 						lowerCamelCase_				(  __A  :		Dict			,	__A  :		Tuple			):
     lowerCamelCase__				=datasets.Dataset.from_file(
         filename=os.path.join(__A			,	'beta.arrow'			)			,	info=datasets.DatasetInfo(features=__A			)			)
     for col in feats:
          lowerCamelCase__				=dataset[col]




@get_duration
def 						lowerCamelCase_				(  __A  :		Optional[Any]			,	__A  :		Optional[Any]			):
     lowerCamelCase__				=datasets.Dataset.from_file(
         filename=os.path.join(__A			,	'beta.arrow'			)			,	info=datasets.DatasetInfo(features=__A			)			)
     dataset.set_format('numpy'			)
     for col in feats:
          lowerCamelCase__				=dataset[col]




def 						lowerCamelCase_				(  ):
     lowerCamelCase__				={}
     lowerCamelCase__				=(
         read_unformated,
         read_formatted_as_numpy,
         read_batch_unformated,
         read_batch_formatted_as_numpy,
         read_col_unformated,
         read_col_formatted_as_numpy,
     )
     with tempfile.TemporaryDirectory() as tmp_dir:
          lowerCamelCase__				=datasets.Features({'image': ArrayaD(__A			,	dtype='float32'			)}			)
          lowerCamelCase__				=generate_examples(features=__A			,	num_examples=__A			)
          lowerCamelCase__				=write(__A			,	__A			,	__A			)
          for read_func in read_functions:
               lowerCamelCase__				=read_func(__A			,	__A			)

     with tempfile.TemporaryDirectory() as tmp_dir:
          # don't use fixed length for fair comparison
          # feats = datasets.Features(
          #     {"image": datasets.Sequence(datasets.Sequence(datasets.Value("float32"), SPEED_TEST_SHAPE[1]), SPEED_TEST_SHAPE[0])}
          # )
          lowerCamelCase__				=datasets.Features({'image': datasets.Sequence(datasets.Sequence(datasets.Value('float32'			)			)			)}			)
          lowerCamelCase__				=generate_examples(
              features=__A			,	num_examples=__A			,	seq_shapes={'image': SPEED_TEST_SHAPE}			)
          lowerCamelCase__				=write(__A			,	__A			,	__A			)
          for read_func in read_functions:
               lowerCamelCase__				=read_func(__A			,	__A			)

     with tempfile.TemporaryDirectory() as tmp_dir:
          # don't use fixed length for fair comparison
          # feats = datasets.Features(
          #     {"image": datasets.Sequence(datasets.Value("float32"), SPEED_TEST_SHAPE[0] * SPEED_TEST_SHAPE[1])}
          # )
          lowerCamelCase__				=datasets.Features({'image': datasets.Sequence(datasets.Value('float32'			)			)}			)
          lowerCamelCase__				=generate_examples(
              features=__A			,	num_examples=__A			,	seq_shapes={'image': [SPEED_TEST_SHAPE[0] * SPEED_TEST_SHAPE[1]]}			,	)
          lowerCamelCase__				=write(__A			,	__A			,	__A			)
          for read_func in read_functions:
               lowerCamelCase__				=read_func(__A			,	__A			)

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


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







"""simple docstring"""



from doctest import testmod
from math import sqrt




def 						lowerCamelCase_				(  __A  :		int			):
					lowerCamelCase__				=[]
					if num < 1:
										return facs
					facs.append(1			)
					if num == 1:
										return facs
					facs.append(__A			)
					for i in range(2			,	int(sqrt(__A			)			) + 1			):
										if num % i == 0:  # If i is a factor of num
															facs.append(__A			)
															lowerCamelCase__				=num // i  # num//i is the other factor of num
															if d != i:  # If d and i are distinct
																				facs.append(__A			)  # we have found another factor
					facs.sort()
					return facs


if __name__ == "__main__":
						testmod(name="factors_of_a_number", verbose=True)