


import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


_UpperCAmelCase      :	str  =1000_0000_0000
_UpperCAmelCase      :	Union[str, Any]  =1_0000

_UpperCAmelCase  ,       _UpperCAmelCase      :	str  =os.path.split(__file__)
_UpperCAmelCase      :	Optional[int]  =os.path.join(RESULTS_BASEPATH, """results""", RESULTS_FILENAME.replace(""".py""", """.json"""))



def       lowerCAmelCase			(		lowerCAmelCase_			, lowerCAmelCase_			)->			datasets.Dataset:
				lowerCAmelCase_			:   Union[str, Any]     					=					pa.Table.from_pydict({'''col''': [0] * chunk_size}			)
				lowerCAmelCase_			:   Tuple     					=					pa.concat_tables([table] * (num_examples // chunk_size)			)
				return datasets.Dataset(lowerCAmelCase_			, fingerprint='''table_100B'''			)







@dataclass
class 					snake_case__:







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__   :	int
						SCREAMING_SNAKE_CASE__   :	int
						SCREAMING_SNAKE_CASE__   :	int
						SCREAMING_SNAKE_CASE__   :	int




						def     lowercase_			(					self				)       ->     Any:
										lowerCAmelCase_			:   Dict     					=					np.random.default_rng(self.seed				)
										lowerCAmelCase_			:   Any     					=					rng.integers(low=self.low ,    high=self.high ,    size=self.size				).tolist()




						def __iter__(					self				)       ->     List[Any]:
										return iter(self._sampled_values				)




						def __len__(					self				)       ->     List[str]:
										return self.size






@get_duration
def       lowerCAmelCase			(		lowerCAmelCase_			)->			Union[str, Any]:
				lowerCAmelCase_			:   Any     					=					dataset[0]



@get_duration
def       lowerCAmelCase			(		lowerCAmelCase_			)->			Union[str, Any]:
				lowerCAmelCase_			:   Any     					=					dataset[-1]



@get_duration
def       lowerCAmelCase			(		lowerCAmelCase_			)->			Dict:
				lowerCAmelCase_			:   Optional[Any]     					=					dataset[range(len(lowerCAmelCase_			) // 2			, len(lowerCAmelCase_			) // 2 + 1_024			)]



@get_duration
def       lowerCAmelCase			(		lowerCAmelCase_			)->			int:
				lowerCAmelCase_			:   Tuple     					=					dataset[RandIter(0			, len(lowerCAmelCase_			)			, 1_024			, seed=42			)]



def       lowerCAmelCase			(		)->			Optional[int]:
				lowerCAmelCase_			:   Union[str, Any]     					=					{'''num examples''': SPEED_TEST_N_EXAMPLES}
				lowerCAmelCase_			:   int     					=					(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
				print('''generating dataset'''			)
				lowerCAmelCase_			:   List[str]     					=					generate_100B_dataset(num_examples=lowerCAmelCase_			, chunk_size=lowerCAmelCase_			)
				print('''Functions'''			)
				for func in functions:
								print(func.__name__			)
								lowerCAmelCase_			:   str     					=					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_table_100B()



import doctest

import projectq
from projectq.ops import H, Measure



def       lowerCAmelCase			(		lowerCAmelCase_			)->			int:
				lowerCAmelCase_			:   List[Any]     					=					quantum_engine.allocate_qubit()
				H | qubit
				Measure | qubit
				return int(lowerCAmelCase_			)


if __name__ == "__main__":
						doctest.testmod()

						# initialises a new quantum backend
						_UpperCAmelCase      :	str  =projectq.MainEngine()

						# Generate a list of 10 random numbers
						_UpperCAmelCase      :	Optional[int]  =[get_random_number(quantum_engine) for _ in range(10)]

						# Flushes the quantum engine from memory
						quantum_engine.flush()

						print("""Random numbers""", random_numbers_list)