



import timeit

import numpy as np

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD






def      __lowercase       (			a__       )    ->			Tuple:
							def wrapper(*a__							,       **a__       ):
														__SCREAMING_SNAKE_CASE									= timeit.default_timer()
														__SCREAMING_SNAKE_CASE									= func(*__lowerCamelCase							,       **__lowerCamelCase       )
														__SCREAMING_SNAKE_CASE									= timeit.default_timer() - starttime
														return delta

							__SCREAMING_SNAKE_CASE									= func.__name__

							return wrapper






def      __lowercase       (			a__							,       a__=1_00							,       a__=None       )    ->			Tuple:
							__SCREAMING_SNAKE_CASE									= []
							__SCREAMING_SNAKE_CASE									= seq_shapes or {}
							for i in range(__lowerCamelCase       ):
														__SCREAMING_SNAKE_CASE									= {}
														for col_id, (k, v) in enumerate(features.items()       ):
																					if isinstance(__lowerCamelCase							,       _ArrayXD       ):
																												__SCREAMING_SNAKE_CASE									= np.random.rand(*v.shape       ).astype(v.dtype       )
																					elif isinstance(__lowerCamelCase							,       datasets.Value       ):
																												if v.dtype == "string":
																																			__SCREAMING_SNAKE_CASE									= "The small grey turtle was surprisingly fast when challenged."
																												else:
																																			__SCREAMING_SNAKE_CASE									= np.random.randint(10							,       size=1       ).astype(v.dtype       ).item()
																					elif isinstance(__lowerCamelCase							,       datasets.Sequence       ):
																												while isinstance(__lowerCamelCase							,       datasets.Sequence       ):
																																			__SCREAMING_SNAKE_CASE									= v.feature
																												__SCREAMING_SNAKE_CASE									= seq_shapes[k]
																												__SCREAMING_SNAKE_CASE									= np.random.rand(*__lowerCamelCase       ).astype(v.dtype       )
																					__SCREAMING_SNAKE_CASE									= data

														dummy_data.append((i, example)       )

							return dummy_data






def      __lowercase       (			a__							,       a__							,       a__=1_00							,       a__=None       )    ->			str:
							__SCREAMING_SNAKE_CASE									= generate_examples(__lowerCamelCase							,       num_examples=__lowerCamelCase							,       seq_shapes=__lowerCamelCase       )

							with ArrowWriter(features=__lowerCamelCase							,       path=__lowerCamelCase       ) as writer:
														for key, record in dummy_data:
																					__SCREAMING_SNAKE_CASE									= features.encode_example(__lowerCamelCase       )
																					writer.write(__lowerCamelCase       )

														__SCREAMING_SNAKE_CASE									= writer.finalize()

							if not num_final_examples == num_examples:
														raise ValueError(
														    f"""Error writing the dataset, wrote {num_final_examples} examples but should have written {num_examples}."""       )

							__SCREAMING_SNAKE_CASE									= datasets.Dataset.from_file(filename=__lowerCamelCase							,       info=datasets.DatasetInfo(features=__lowerCamelCase       )       )

							return dataset











lowerCAmelCase__		:					Optional[int]							=9.80_665






def      __lowercase       (			a__							,       a__							,       a__ = g       )    ->			float:

							if fluid_density <= 0:
														raise ValueError('Impossible fluid density'       )
							if volume < 0:
														raise ValueError('Impossible Object volume'       )
							if gravity <= 0:
														raise ValueError('Impossible Gravity'       )

							return fluid_density * gravity * volume


if __name__ == "__main__":
			import doctest

			# run doctest
			doctest.testmod()






