I am currently working in jupyter lab and want to do a quick assertion in order to validate that a function is working as expected. Here is the recreation of what I am doing:
np.random.seed(0)
@njit(parallel=True)
def sum_shape(repeats,samples):
sum = 0
for i in prange(0,repeats):
x = np.random.uniform(0,100,int(samples))
sum += np.sum(x)
return sum
print(sum_shape(100,1000))
time1 = time.time() - start1
print(time1)
%%ipytest
np.random.seed(0)
def test():
assert sum_shape(100,1000) == 5015855.398294773 # expected output given seed
The problem I currently face is with how parallelization works, pulling numbers from different seeds per thread, so I am wondering how to combat this. I want to have the test still compare to an expected output while being efficient.
Thanks.