-
Notifications
You must be signed in to change notification settings - Fork 10
/
defs.py
37 lines (28 loc) · 1014 Bytes
/
defs.py
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
34
35
36
import multiprocessing as mp
import numpy as np
import scipy.signal
def get_cpu_count():
return mp.cpu_count()
def is_prime(n):
for divisor in range(2, int(n ** 0.5) + 1):
if n % divisor == 0:
return 0
return 1
def inefficient_fib(n=None):
"""Compute intensive calculation for the nth fibonacci number"""
if n <= 1:
return n
return inefficient_fib(n - 1) + inefficient_fib(n - 2)
iterations_count = iterations_count = round(1e4)
def complex_operation_numpy(index):
data = np.ones(iterations_count)
val = np.exp(data) * np.sinh(data)
return val.sum()
def f_ray_image_signal(args):
image, random_filter = args
# Do some image processing: convolve two 2-dimensional arrays.
return scipy.signal.convolve2d(image, random_filter)[::5, ::5]
def f_py_image_signal(args):
image, random_filter = args
# Do some image processing: convolve two 2-dimensional arrays.
return scipy.signal.convolve2d(image, random_filter)[::5, ::5]