Skip to content

Commit 462035d

Browse files
committed
add gc.collect() not sure it is efficient...
1 parent f1bc017 commit 462035d

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,4 @@ docs/_syracuseC.so.dSYM/Contents/Info.plist
120120
docs/a.out
121121
_build
122122
a.out
123+
julia_set.jl

03.julia-set.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
# This is a modified version from [Loic Gouarin](https://github.com/gouarin/GTSage2014/)
2424
#
2525
# The test case is the computation of the Julia set [wikipedia](https://en.wikipedia.org/wiki/Julia_set)
26-
# -
2726

28-
import os, sys
27+
# +
28+
import os, sys, gc
29+
2930
if sys.platform == 'darwin':
3031
os.environ['CC'] = 'gcc-10'
3132
os.environ['CXX'] = 'g++-10'
33+
# -
3234

3335
import warnings
3436
warnings.filterwarnings('ignore')
@@ -83,6 +85,7 @@ def juliaset_python(x, y, c, lim, maxit):
8385
def plot_julia_set(julia):
8486
plt.figure(figsize=(6,6))
8587
plt.imshow(julia, cmap = cm.Greys, vmin=vmin, vmax=vmax)
88+
gc.collect()
8689

8790

8891
# + {"internals": {"slide_helper": "subslide_end"}, "slide_helper": "slide_end", "slideshow": {"slide_type": "-"}}

notebooks/03.julia-set.ipynb

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,20 @@
2424
},
2525
{
2626
"cell_type": "code",
27-
"execution_count": 1,
27+
"execution_count": 9,
2828
"metadata": {},
2929
"outputs": [],
3030
"source": [
31-
"import os, sys\n",
31+
"import os, sys, gc\n",
32+
"\n",
3233
"if sys.platform == 'darwin':\n",
3334
" os.environ['CC'] = 'gcc-10'\n",
3435
" os.environ['CXX'] = 'g++-10'"
3536
]
3637
},
3738
{
3839
"cell_type": "code",
39-
"execution_count": 2,
40+
"execution_count": 10,
4041
"metadata": {},
4142
"outputs": [],
4243
"source": [
@@ -46,7 +47,7 @@
4647
},
4748
{
4849
"cell_type": "code",
49-
"execution_count": 3,
50+
"execution_count": 11,
5051
"metadata": {
5152
"internals": {
5253
"slide_helper": "subslide_end",
@@ -65,7 +66,7 @@
6566
},
6667
{
6768
"cell_type": "code",
68-
"execution_count": 4,
69+
"execution_count": 12,
6970
"metadata": {
7071
"internals": {
7172
"slide_helper": "subslide_end",
@@ -94,7 +95,7 @@
9495
},
9596
{
9697
"cell_type": "code",
97-
"execution_count": 5,
98+
"execution_count": 13,
9899
"metadata": {
99100
"internals": {
100101
"slide_helper": "subslide_end"
@@ -131,7 +132,7 @@
131132
},
132133
{
133134
"cell_type": "code",
134-
"execution_count": 6,
135+
"execution_count": 14,
135136
"metadata": {
136137
"internals": {},
137138
"slideshow": {
@@ -160,7 +161,7 @@
160161
},
161162
{
162163
"cell_type": "code",
163-
"execution_count": 7,
164+
"execution_count": 15,
164165
"metadata": {
165166
"internals": {},
166167
"slideshow": {
@@ -171,12 +172,13 @@
171172
"source": [
172173
"def plot_julia_set(julia):\n",
173174
" plt.figure(figsize=(6,6))\n",
174-
" plt.imshow(julia, cmap = cm.Greys, vmin=vmin, vmax=vmax)"
175+
" plt.imshow(julia, cmap = cm.Greys, vmin=vmin, vmax=vmax)\n",
176+
" gc.collect()"
175177
]
176178
},
177179
{
178180
"cell_type": "code",
179-
"execution_count": 8,
181+
"execution_count": 16,
180182
"metadata": {
181183
"internals": {
182184
"slide_helper": "subslide_end"
@@ -233,7 +235,7 @@
233235
},
234236
{
235237
"cell_type": "code",
236-
"execution_count": 9,
238+
"execution_count": 17,
237239
"metadata": {
238240
"lines_to_next_cell": 2
239241
},
@@ -247,7 +249,7 @@
247249
},
248250
{
249251
"cell_type": "code",
250-
"execution_count": 10,
252+
"execution_count": 18,
251253
"metadata": {},
252254
"outputs": [
253255
{
@@ -290,7 +292,7 @@
290292
},
291293
{
292294
"cell_type": "code",
293-
"execution_count": 11,
295+
"execution_count": 19,
294296
"metadata": {},
295297
"outputs": [],
296298
"source": [
@@ -300,7 +302,7 @@
300302
},
301303
{
302304
"cell_type": "code",
303-
"execution_count": 12,
305+
"execution_count": 20,
304306
"metadata": {},
305307
"outputs": [
306308
{
@@ -350,7 +352,7 @@
350352
},
351353
{
352354
"cell_type": "code",
353-
"execution_count": 13,
355+
"execution_count": 21,
354356
"metadata": {},
355357
"outputs": [],
356358
"source": [
@@ -359,7 +361,7 @@
359361
},
360362
{
361363
"cell_type": "code",
362-
"execution_count": 14,
364+
"execution_count": 22,
363365
"metadata": {
364366
"slideshow": {
365367
"slide_type": "fragment"
@@ -393,7 +395,7 @@
393395
},
394396
{
395397
"cell_type": "code",
396-
"execution_count": 15,
398+
"execution_count": 23,
397399
"metadata": {},
398400
"outputs": [
399401
{
@@ -428,7 +430,7 @@
428430
},
429431
{
430432
"cell_type": "code",
431-
"execution_count": 16,
433+
"execution_count": 24,
432434
"metadata": {
433435
"lines_to_next_cell": 2
434436
},
@@ -471,7 +473,7 @@
471473
},
472474
{
473475
"cell_type": "code",
474-
"execution_count": 17,
476+
"execution_count": 25,
475477
"metadata": {},
476478
"outputs": [],
477479
"source": [
@@ -515,7 +517,7 @@
515517
},
516518
{
517519
"cell_type": "code",
518-
"execution_count": 18,
520+
"execution_count": 26,
519521
"metadata": {},
520522
"outputs": [
521523
{
@@ -552,7 +554,7 @@
552554
},
553555
{
554556
"cell_type": "code",
555-
"execution_count": 19,
557+
"execution_count": 27,
556558
"metadata": {},
557559
"outputs": [],
558560
"source": [
@@ -602,7 +604,7 @@
602604
},
603605
{
604606
"cell_type": "code",
605-
"execution_count": 20,
607+
"execution_count": 28,
606608
"metadata": {},
607609
"outputs": [
608610
{
@@ -644,7 +646,7 @@
644646
},
645647
{
646648
"cell_type": "code",
647-
"execution_count": 21,
649+
"execution_count": 29,
648650
"metadata": {
649651
"internals": {
650652
"slide_helper": "subslide_end"
@@ -677,7 +679,7 @@
677679
},
678680
{
679681
"cell_type": "code",
680-
"execution_count": 22,
682+
"execution_count": 30,
681683
"metadata": {},
682684
"outputs": [
683685
{
@@ -723,7 +725,7 @@
723725
},
724726
{
725727
"cell_type": "code",
726-
"execution_count": 23,
728+
"execution_count": 31,
727729
"metadata": {
728730
"internals": {},
729731
"slideshow": {
@@ -737,7 +739,7 @@
737739
},
738740
{
739741
"cell_type": "code",
740-
"execution_count": 24,
742+
"execution_count": 32,
741743
"metadata": {
742744
"internals": {
743745
"slide_helper": "subslide_end",
@@ -778,7 +780,7 @@
778780
},
779781
{
780782
"cell_type": "code",
781-
"execution_count": 25,
783+
"execution_count": 33,
782784
"metadata": {},
783785
"outputs": [
784786
{
@@ -811,7 +813,7 @@
811813
},
812814
{
813815
"cell_type": "code",
814-
"execution_count": 26,
816+
"execution_count": 34,
815817
"metadata": {
816818
"internals": {
817819
"slide_helper": "subslide_end"
@@ -826,15 +828,15 @@
826828
"name": "stdout",
827829
"output_type": "stream",
828830
"text": [
829-
"[1/1] Cythonizing /Users/navaro/.ipython/cython/_cython_magic_2b7b0547f4ab4801c04ebf306812bde8.pyx\n",
831+
"[1/1] Cythonizing /Users/navaro/.ipython/cython/_cython_magic_af0f26f19418fe7b67ea74586ba9274b.pyx\n",
830832
"new_compiler returns <class 'distutils.unixccompiler.UnixCCompiler'>\n",
831-
"building '_cython_magic_2b7b0547f4ab4801c04ebf306812bde8' extension\n",
833+
"building '_cython_magic_af0f26f19418fe7b67ea74586ba9274b' extension\n",
832834
"C compiler: gcc-10 -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers\n",
833835
"\n",
834836
"compile options: '-I/usr/local/lib/python3.8/site-packages/numpy/core/include -I/usr/local/Cellar/[email protected]/3.8.5/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c'\n",
835837
"extra options: '-fopenmp'\n",
836-
"gcc-10: /Users/navaro/.ipython/cython/_cython_magic_2b7b0547f4ab4801c04ebf306812bde8.c\n",
837-
"gcc-10 -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk /Users/navaro/.ipython/cython/Users/navaro/.ipython/cython/_cython_magic_2b7b0547f4ab4801c04ebf306812bde8.o -o /Users/navaro/.ipython/cython/_cython_magic_2b7b0547f4ab4801c04ebf306812bde8.cpython-38-darwin.so -fopenmp\n"
838+
"gcc-10: /Users/navaro/.ipython/cython/_cython_magic_af0f26f19418fe7b67ea74586ba9274b.c\n",
839+
"gcc-10 -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk /Users/navaro/.ipython/cython/Users/navaro/.ipython/cython/_cython_magic_af0f26f19418fe7b67ea74586ba9274b.o -o /Users/navaro/.ipython/cython/_cython_magic_af0f26f19418fe7b67ea74586ba9274b.cpython-38-darwin.so -fopenmp\n"
838840
]
839841
}
840842
],
@@ -872,7 +874,7 @@
872874
},
873875
{
874876
"cell_type": "code",
875-
"execution_count": 27,
877+
"execution_count": 35,
876878
"metadata": {},
877879
"outputs": [
878880
{

0 commit comments

Comments
 (0)