Skip to content

Commit

Permalink
[L6] Correct misplaced parenthesis
Browse files Browse the repository at this point in the history
Fix barbagroup#60

The parenthesis in In [6] were miscplaced.
@fidle caught the bug and opened an issue (barbagroup#60).
Thank you for reporting the error @fidle.

Also:

* Re-run notebook to get updated execution times.
* Update execution times in Markdown cells.
* Add info about machine used to re-run notebook.
  • Loading branch information
mesnardo committed Apr 8, 2019
1 parent 2139adb commit 3c692c4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lessons/06_Array_Operations_with_NumPy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"1 loop, best of 3: 1.94 s per loop\n"
"3.07 s ± 15.1 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
Expand Down Expand Up @@ -189,7 +189,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"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:"
"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:"
]
},
{
Expand All @@ -201,7 +201,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"100 loops, best of 3: 5.09 ms per loop\n"
"7.38 ms ± 105 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
]
}
],
Expand All @@ -212,7 +212,7 @@
"\n",
"for n in range(nt + 1): ##loop across number of time steps\n",
" un = u.copy()\n",
" u[1:, 1:] = un[1:, 1:] - ((c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) -\n",
" u[1:, 1:] = (un[1:, 1:] - (c * dt / dx * (un[1:, 1:] - un[1:, 0:-1])) -\n",
" (c * dt / dy * (un[1:, 1:] - un[0:-1, 1:])))\n",
" u[0, :] = 1\n",
" u[-1, :] = 1\n",
Expand All @@ -224,7 +224,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"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. "
"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. "
]
},
{
Expand Down Expand Up @@ -353,7 +353,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 3c692c4

Please sign in to comment.