/usr/share/doc/numba-doc/examples/pi.py is in numba-doc 0.34.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #
# Copyright (c) 2017 Intel Corporation
# SPDX-License-Identifier: BSD-2-Clause
#
import numba
import numpy as np
import argparse
import time
run_parallel = numba.config.NUMBA_NUM_THREADS > 1
@numba.njit(parallel=run_parallel)
def calc_pi(n):
x = 2*np.random.ranf(n)-1
y = 2*np.random.ranf(n)-1
return 4*np.sum(x**2+y**2<1)/n
def main():
parser = argparse.ArgumentParser(description='Calculate Pi.')
parser.add_argument('--points', dest='points', type=int, default=20000000)
args = parser.parse_args()
points = args.points
np.random.seed(0)
t1 = time.time()
pi = calc_pi(points)
selftimed = time.time()-t1
print("SELFTIMED ", selftimed)
print("result: ", pi)
if __name__ == '__main__':
main()
|