Skip to content

Commit b7293d8

Browse files
committed
a lot of test
1 parent 4e6f3d9 commit b7293d8

21 files changed

+12137
-6
lines changed
919 Bytes
Binary file not shown.
Binary file not shown.

demos/cython/mandel_cyt.c

Lines changed: 8382 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

demos/cython/mandel_cyt.html

Lines changed: 832 additions & 0 deletions
Large diffs are not rendered by default.

demos/cython/mandel_main_cp.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
import sys
4+
from mandel import compute_mandel as compute_mandel_py
5+
try:
6+
from mandel_cyt import compute_mandel as compute_mandel_cyt
7+
except ImportError:
8+
pass
9+
10+
def plot_mandel(mandel):
11+
plt.imshow(mandel)
12+
plt.axis('off')
13+
plt.show()
14+
15+
def main(version='py'):
16+
kwargs = dict(cr=0.285, ci=0.01,
17+
N=200,
18+
bound=1.5)
19+
20+
# choose pure Python or Cython version
21+
if version == 'py':
22+
print("Using pure Python")
23+
mandel_func = compute_mandel_py
24+
elif version == 'cyt':
25+
print("Using Cython")
26+
try:
27+
mandel_func = compute_mandel_cyt
28+
except NameError as ex:
29+
raise RuntimeError("Cython extension missing") from ex
30+
else:
31+
raise RuntimeError("Unknown version")
32+
33+
mandel_set, runtime = mandel_func(**kwargs)
34+
return mandel_set, runtime
35+
36+
if __name__ == '__main__':
37+
if len(sys.argv) == 2:
38+
mandel_set, runtime = main('cyt')
39+
else:
40+
mandel_set, runtime = main()
41+
print('Mandelbrot set generated in {0:9.4f} seconds'.format(runtime))
42+
plot_mandel(mandel_set)
43+
44+

demos/cython/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from distutils.core import setup, Extension
22
from Cython.Build import cythonize
3+
import numpy
34

45
setup(
5-
ext_modules=cythonize("mandel_cyt.pyx"),
6+
ext_modules=cythonize("mandel_cyt.pyx",compiler_directives = {'language_level': 3}),include_dirs = [numpy.get_include()],
67
)
78

demos/memory_usage.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ def maxmem():
2424

2525
a = np.random.random((1024, 1024, 10))
2626
b = np.random.random((1024, 1024, 10))
27-
c = a - b
27+
#c = a - b
2828
#c = 2.0 * a - 4.5 * b
2929
#c = 2.0 * a - 4.5 * b + np.sin(a) - np.cos(b)
3030
#c = 2.0 * a - 4.5 * b + (np.sin(a) - np.cos(b))
3131
#c = (np.sin(a) - np.cos(b)) + 2.0 * a - 4.5 * b
3232

33-
#c = 2.0 * a
34-
#c -= 4.5 * b
35-
#c += np.sin(a)
36-
#c -= np.cos(b)
33+
c = 2.0 * a
34+
c -= 4.5 * b
35+
c += np.sin(a)
36+
c -= np.cos(b)
3737

3838
mem = maxmem() - overhead
3939

myfile/.linagtst.py.swp

12 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)