Skip to content

Commit a955baa

Browse files
authored
Merge pull request barbagroup#61 from mesnardo/misplaced-parenthesis
[L6] Correct misplaced parenthesis
2 parents c59c068 + 3c692c4 commit a955baa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lessons/06_Array_Operations_with_NumPy.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
"name": "stdout",
162162
"output_type": "stream",
163163
"text": [
164-
"1 loop, best of 3: 1.94 s per loop\n"
164+
"3.07 s ± 15.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
165165
]
166166
}
167167
],
@@ -189,7 +189,7 @@
189189
"cell_type": "markdown",
190190
"metadata": {},
191191
"source": [
192-
"With the \"raw\" Python code above, the best execution time achieved was 1.94 seconds. Keep in mind that with these three nested loops, that the statements inside the **j** loop are being evaluated more than 650,000 times. Let's compare that with the performance of the same code implemented with array operations:"
192+
"With the \"raw\" Python code above, the mean execution time achieved was 3.07 seconds (on a MacBook Pro Mid 2012). Keep in mind that with these three nested loops, that the statements inside the **j** loop are being evaluated more than 650,000 times. Let's compare that with the performance of the same code implemented with array operations:"
193193
]
194194
},
195195
{
@@ -201,7 +201,7 @@
201201
"name": "stdout",
202202
"output_type": "stream",
203203
"text": [
204-
"100 loops, best of 3: 5.09 ms per loop\n"
204+
"7.38 ms ± 105 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
205205
]
206206
}
207207
],
@@ -212,7 +212,7 @@
212212
"\n",
213213
"for n in range(nt + 1): ##loop across number of time steps\n",
214214
" un = u.copy()\n",
215-
" u[1:, 1:] = un[1:, 1:] - ((c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) -\n",
215+
" u[1:, 1:] = (un[1:, 1:] - (c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) -\n",
216216
" (c * dt / dy * (un[1:, 1:] - un[0:-1, 1:])))\n",
217217
" u[0, :] = 1\n",
218218
" u[-1, :] = 1\n",
@@ -224,7 +224,7 @@
224224
"cell_type": "markdown",
225225
"metadata": {},
226226
"source": [
227-
"As you can see, the speed increase is substantial. The same calculation goes from 1.94 seconds to 5.09 milliseconds. 2 seconds isn't a huge amount of time to wait, but these speed gains will increase exponentially with the size and complexity of the problem being evaluated. "
227+
"As you can see, the speed increase is substantial. The same calculation goes from 3.07 seconds to 7.38 milliseconds. 3 seconds isn't a huge amount of time to wait, but these speed gains will increase exponentially with the size and complexity of the problem being evaluated. "
228228
]
229229
},
230230
{
@@ -353,7 +353,7 @@
353353
"name": "python",
354354
"nbconvert_exporter": "python",
355355
"pygments_lexer": "ipython3",
356-
"version": "3.6.5"
356+
"version": "3.6.8"
357357
}
358358
},
359359
"nbformat": 4,

0 commit comments

Comments
 (0)