@@ -21,7 +21,7 @@ def show(exercice_name):
2121 return function ()
2222
2323
24- def ex4_1 ():
24+ def ex3_1 ():
2525 """ Simple example of an element wise comparaison"""
2626 x = numpy .arange (10 )
2727 y = numpy .arange (1 , 11 )
@@ -30,7 +30,7 @@ def ex4_1():
3030 return difference
3131
3232
33- def ex4_2 ():
33+ def ex3_2 ():
3434 """ Simple way to compute the difference x[i+1]-x[i] for all the elements
3535 of the 1D array"""
3636 x = numpy .arange (10 )
@@ -39,15 +39,15 @@ def ex4_2():
3939 return difference
4040
4141
42- def ex5_1 ():
42+ def ex4_1 ():
4343 """Generate a 1D array of [1..99] then operate a binning 1 2 3 4 -> 1+2 3+4
4444 """
4545 data = numpy .arange (100 ) + 1
4646 binned = data [::2 ] + data [1 ::2 ]
4747 return data , binned
4848
4949
50- def ex5_2 ():
50+ def ex4_2 ():
5151 """Generate a 2D array of [1..9999] then operate a 2x2 binning
5252 """
5353 data = numpy .arange (10000 ).reshape (100 , 100 )
@@ -56,7 +56,7 @@ def ex5_2():
5656 return data , binned
5757
5858
59- def ex5_2_alt ():
59+ def ex4_2_alt ():
6060 """Generate a 2D array of [1..9999] then operate a 2x2 binning using numpy
6161 sum and moving the array to 4D
6262 """
@@ -69,7 +69,7 @@ def ex5_2_alt():
6969 return data , binned
7070
7171
72- def ex6_inefficient_fill (height = 1000 , width = 1000 ):
72+ def ex5_inefficient_fill (height = 1000 , width = 1000 ):
7373 """Inefficient fill using 2 for loops"""
7474 data = numpy .zeros ((height , width ), dtype = numpy .float )
7575 for row in range (int (height )):
@@ -78,7 +78,7 @@ def ex6_inefficient_fill(height=1000, width=1000):
7878 return data
7979
8080
81- def ex6_naive_fill (height = 1000 , width = 1000 ):
81+ def ex5_naive_fill (height = 1000 , width = 1000 ):
8282 """Fill using 2 for loops but pre-computing sin and cos"""
8383 width_sin = numpy .sin (numpy .arange (width ))
8484 height_cos = numpy .cos (numpy .arange (height ))
@@ -89,7 +89,7 @@ def ex6_naive_fill(height=1000, width=1000):
8989 return data
9090
9191
92- def ex6_clever_fill (height = 1000 , width = 1000 ):
92+ def ex5_clever_fill (height = 1000 , width = 1000 ):
9393 """Fill using 2 outer products"""
9494 width_sin = numpy .sin (numpy .arange (width ))
9595 height_cos = numpy .cos (numpy .arange (height ))
@@ -98,22 +98,22 @@ def ex6_clever_fill(height=1000, width=1000):
9898 return cos_loop * sin_loop
9999
100100
101- def ex6_practical_fill (height = 1000 , width = 1000 ):
101+ def ex5_practical_fill (height = 1000 , width = 1000 ):
102102 """Fill using meshgrid"""
103103 width_sin = numpy .sin (numpy .arange (width ))
104104 height_cos = numpy .cos (numpy .arange (height ))
105105 sin_loop , cos_loop = numpy .meshgrid (width_sin , height_cos )
106106 return sin_loop * cos_loop
107107
108108
109- def ex6_optimized_fill (height = 1000 , width = 1000 ):
109+ def ex5_optimized_fill (height = 1000 , width = 1000 ):
110110 """Fill using outer product"""
111111 width_sin = numpy .sin (numpy .arange (width ))
112112 height_cos = numpy .cos (numpy .arange (height ))
113113 return numpy .outer (height_cos , width_sin )
114114
115115
116- def ex6_atleast_2d_fill (height = 1000 , width = 1000 ):
116+ def ex5_atleast_2d_fill (height = 1000 , width = 1000 ):
117117 """Fill using atleast_2d and transpose"""
118118 sine = numpy .sin (numpy .arange (width ))
119119 cosine = numpy .cos (numpy .arange (height ))
0 commit comments