


import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


A_    :					Any             =100000000000
A_    :					Tuple             =10000

A_       ,	A_    :					Tuple             =os.path.split(__file__)
A_    :					str             =os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))




def   lowerCamelCase_       (					UpperCAmelCase__       ,    UpperCAmelCase__      ):



						"""simple docstring"""




						a_					=		pa.Table.from_pydict({"""col""": [0] * chunk_size}      )
						a_					=		pa.concat_tables([table] * (num_examples // chunk_size)      )
						return datasets.Dataset(UpperCAmelCase__       ,    fingerprint="""table_100B"""      )





@dataclass
class        lowercase_				:






							"""simple docstring"""







							snake_case_        =		42
							snake_case_        =		42
							snake_case_        =		42
							snake_case_        =		42


							def 						lowercase__     (   self		):







													"""simple docstring"""


													a_					=		np.random.default_rng(self.seed		)
													a_					=		rng.integers(low=self.low			,    high=self.high			,    size=self.size		).tolist()


							def __iter__(   self		):







													"""simple docstring"""


													return iter(self._sampled_values		)






							def __len__(   self		):







													"""simple docstring"""


													return self.size




@get_duration
def   lowerCamelCase_       (					UpperCAmelCase__      ):



						"""simple docstring"""




						a_					=		dataset[0]




@get_duration
def   lowerCamelCase_       (					UpperCAmelCase__      ):



						"""simple docstring"""




						a_					=		dataset[-1]




@get_duration
def   lowerCamelCase_       (					UpperCAmelCase__      ):



						"""simple docstring"""




						a_					=		dataset[range(len(UpperCAmelCase__      ) // 2       ,    len(UpperCAmelCase__      ) // 2 + 1_024      )]




@get_duration
def   lowerCamelCase_       (					UpperCAmelCase__      ):



						"""simple docstring"""




						a_					=		dataset[RandIter(0       ,    len(UpperCAmelCase__      )       ,    1_024       ,    seed=42      )]




def   lowerCamelCase_       (					):



						"""simple docstring"""




						a_					=		{"""num examples""": SPEED_TEST_N_EXAMPLES}
						a_					=		(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
						print("""generating dataset"""      )
						a_					=		generate_100B_dataset(num_examples=UpperCAmelCase__       ,    chunk_size=UpperCAmelCase__      )
						print("""Functions"""      )
						for func in functions:
												print(func.__name__      )
												a_					=		func(UpperCAmelCase__      )

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


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



from collections.abc import Callable

A_    :					Any             =Callable[[float], float]  # type alias for a real -> real function




def   lowerCamelCase_       (					UpperCAmelCase__       ,    UpperCAmelCase__       ,    UpperCAmelCase__       ,    ):



						"""simple docstring"""




						a_					=		float(UpperCAmelCase__      )
						while True:
												try:
																		a_					=		prev_guess - function(UpperCAmelCase__      ) / derivative(UpperCAmelCase__      )
												except ZeroDivisionError:
																		raise ZeroDivisionError("""Could not find root"""      ) from None
												if abs(prev_guess - next_guess      ) < 10**-5:
																		return next_guess
												a_					=		next_guess




def   lowerCamelCase_       (					UpperCAmelCase__      ):



						"""simple docstring"""




						return (x**3) - (2 * x) - 5




def   lowerCamelCase_       (					UpperCAmelCase__      ):



						"""simple docstring"""




						return 3 * (x**2) - 2


if __name__ == "__main__":
	print(newton(f, fa, 3))