Skip to content

Commit 81e8aeb

Browse files
committed
Merge branch 'add_ipythonblocks_image' of abostroem/python-novice-inflammation into gh-pages
* 'add_ipythonblocks_image' of https://github.com/abostroem/python-novice-inflammation: regenerating html adding ipythonblocks show_color example to fix last FIXME
2 parents e6b5c8b + 677cc68 commit 81e8aeb

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

discussion.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ <h2 id="the-call-stack">The Call Stack</h2>
8080
<p>The big idea here is <a href="reference.html#encapsulation">encapsulation</a>, and it’s the key to writing correct, comprehensible programs. A function’s job is to turn several operations into one so that we can think about a single function call instead of a dozen or a hundred statements each time we want to do something. That only works if functions don’t interfere with each other; if they do, we have to pay attention to the details once again, which quickly overloads our short-term memory.</p>
8181
<section class="challenge panel panel-success">
8282
<div class="panel-heading">
83-
<h2 id="following-the-call-stack"><span class="glyphicon glyphicon-pencil"></span>Following the call stack</h2>
83+
<h2><span class="glyphicon glyphicon-pencil"></span>Following the call stack</h2>
8484
</div>
8585
<div class="panel-body">
8686
<p>We previously wrote functions called <code>fence</code> and <code>outer</code>. Draw a diagram showing how the call stack changes when we run the following:</p>
@@ -96,7 +96,6 @@ <h2 id="image-grids">Image Grids</h2>
9696
grid.show()</code></pre>
9797
<div class="figure">
9898
<img src="img/grid-01.png" />
99-
10099
</div>
101100
<p>Just like a NumPy array, an <code>ImageGrid</code> has some properties that hold information about it:</p>
102101
<pre class="sourceCode python"><code class="sourceCode python"><span class="dt">print</span> <span class="st">&#39;grid width:&#39;</span>, grid.width
@@ -107,8 +106,7 @@ <h2 id="image-grids">Image Grids</h2>
107106
grid lines on: True</code></pre>
108107
<p>The obvious thing to do with a grid like this is color in its cells, but in order to do that, we need to know how computers represent color. The most common schemes are <a href="reference.html#rgb">RGB</a>, which is short for “red, green, blue”. RGB is an <a href="reference.html#additive-color-model">additive color model</a>: every shade is some combination of red, green, and blue intensities. We can think of these three values as being the axes in a cube:</p>
109108
<div class="figure">
110-
<img src="fig/color-cube.png" alt="RGB Color Cube" />
111-
<p class="caption">RGB Color Cube</p>
109+
<img src="fig/color-cube.png" alt="RGB Color Cube" /><p class="caption">RGB Color Cube</p>
112110
</div>
113111
<p>An RGB color is an example of a multi-part value: like a Cartesian coordinate, it is one thing with several parts. We can represent such a value in Python using a <a href="reference.html#tuple">tuple</a>, which we write using parentheses instead of the square brackets used for a list:</p>
114112
<pre class="sourceCode python"><code class="sourceCode python">position = (<span class="fl">12.3</span>, <span class="fl">45.6</span>)
@@ -144,12 +142,13 @@ <h2 id="image-grids">Image Grids</h2>
144142
row.show()</code></pre>
145143
<div class="figure">
146144
<img src="img/grid-02.png" />
147-
148145
</div>
149146
<p>Simple color values like <code>(0,255,0)</code> are easy enough to decipher with a bit of practice, but what color is <code>(214,90,127)</code>? To help us, <code>ipythonblocks</code> provides a function called <code>show_color</code>:</p>
150147
<pre class="sourceCode python"><code class="sourceCode python"><span class="ch">from</span> ipythonblocks <span class="ch">import</span> show_color
151148
show_color(<span class="dv">214</span>, <span class="dv">90</span>, <span class="dv">127</span>)</code></pre>
152-
<p>FIXME: color image</p>
149+
<div class="figure">
150+
<img src="fig/ipythonblocks_show_color_example.png" />
151+
</div>
153152
<p>It also provides a table of standard colors:</p>
154153
<pre class="sourceCode python"><code class="sourceCode python"><span class="ch">from</span> ipythonblocks <span class="ch">import</span> colors
155154
c = ImageGrid(<span class="dv">3</span>, <span class="dv">2</span>)
@@ -162,11 +161,10 @@ <h2 id="image-grids">Image Grids</h2>
162161
c.show()</code></pre>
163162
<div class="figure">
164163
<img src="img/grid-03.png" />
165-
166164
</div>
167165
<section class="challenge panel panel-success">
168166
<div class="panel-heading">
169-
<h2 id="making-a-colorbar"><span class="glyphicon glyphicon-pencil"></span>Making a colorbar</h2>
167+
<h2><span class="glyphicon glyphicon-pencil"></span>Making a colorbar</h2>
170168
</div>
171169
<div class="panel-body">
172170
<p>Fill in the <code>____</code> in the code below to create a bar that changes color from dark blue to black.</p>
@@ -178,31 +176,31 @@ <h2 id="making-a-colorbar"><span class="glyphicon glyphicon-pencil"></span>Makin
178176
</section>
179177
<section class="challenge panel panel-success">
180178
<div class="panel-heading">
181-
<h2 id="why-rgb"><span class="glyphicon glyphicon-pencil"></span>Why RGB?</h2>
179+
<h2><span class="glyphicon glyphicon-pencil"></span>Why RGB?</h2>
182180
</div>
183181
<div class="panel-body">
184182
<p>Why do computers use red, green, and blue as their primary colors?</p>
185183
</div>
186184
</section>
187185
<section class="challenge panel panel-success">
188186
<div class="panel-heading">
189-
<h2 id="nested-loops"><span class="glyphicon glyphicon-pencil"></span>Nested loops</h2>
187+
<h2><span class="glyphicon glyphicon-pencil"></span>Nested loops</h2>
190188
</div>
191189
<div class="panel-body">
192190
<p>Will changing the nesting of the loops in the code above — i.e., wrapping the Y-axis loop around the X-axis loop — change the final image? Why or why not?</p>
193191
</div>
194192
</section>
195193
<section class="challenge panel panel-success">
196194
<div class="panel-heading">
197-
<h2 id="where-to-change-data"><span class="glyphicon glyphicon-pencil"></span>Where to change data</h2>
195+
<h2><span class="glyphicon glyphicon-pencil"></span>Where to change data</h2>
198196
</div>
199197
<div class="panel-body">
200198
<p>Why did we transpose our data outside our heat map function? Why not have the function perform the transpose?</p>
201199
</div>
202200
</section>
203201
<section class="challenge panel panel-success">
204202
<div class="panel-heading">
205-
<h2 id="design-choice-return-versus-display"><span class="glyphicon glyphicon-pencil"></span>Design choice: return versus display</h2>
203+
<h2><span class="glyphicon glyphicon-pencil"></span>Design choice: return versus display</h2>
206204
</div>
207205
<div class="panel-body">
208206
<p>Why does the heat map function return the grid rather than displaying it immediately? Do you think this is a good or bad design choice?</p>

discussion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ from ipythonblocks import show_color
295295
show_color(214, 90, 127)
296296
~~~
297297

298-
FIXME: color image
298+
![](fig/ipythonblocks_show_color_example.png)
299299

300300
It also provides a table of standard colors:
301301

4.37 KB
Loading

0 commit comments

Comments
 (0)