Skip to content

Commit

Permalink
point all the image src URIs to use the fig/ path
Browse files Browse the repository at this point in the history
And change the `<img>` tags to use Markdown's `![caption](/path/to/image)`
syntax.
  • Loading branch information
zmughal committed Jan 19, 2015
1 parent b609b98 commit 0875a72
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
18 changes: 9 additions & 9 deletions 01-numpy.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ we can print several things at once by separating them with commas.
If we imagine the variable as a sticky note with a name written on it,
assignment is like putting the sticky note on a particular value:

<img src="img/python-sticky-note-variables-01.svg" alt="Variables as Sticky Notes" />
![Variables as Sticky Notes](fig/python-sticky-note-variables-01.svg)

This means that assigning a value to one variable does *not* change the values of other variables.
For example,
Expand All @@ -138,7 +138,7 @@ print 'weight in kilograms:', weight_kg, 'and in pounds:', weight_lb
weight in kilograms: 57.5 and in pounds: 126.5
~~~

<img src="img/python-sticky-note-variables-02.svg" alt="Creating Another Variable" />
![Creating Another Variable](fig/python-sticky-note-variables-02.svg)

and then change `weight_kg`:

Expand All @@ -150,7 +150,7 @@ print 'weight in kilograms is now:', weight_kg, 'and weight in pounds is still:'
weight in kilograms is now: 100.0 and weight in pounds is still: 126.5
~~~

<img src="img/python-sticky-note-variables-03.svg" alt="Updating a Variable" />
![Updating a Variable](fig/python-sticky-note-variables-03.svg)

Since `weight_lb` doesn't "remember" where its value came from,
it isn't automatically updated when `weight_kg` changes.
Expand Down Expand Up @@ -434,7 +434,7 @@ or the average for each day?
As the diagram below shows,
we want to perform the operation across an axis:

<img src="img/python-operations-across-axes.svg" alt="Operations Across Axes" />
![Operations Across Axes](fig/python-operations-across-axes.svg)

To support this,
most array methods allow us to specify the axis we want to work on.
Expand Down Expand Up @@ -500,7 +500,7 @@ pyplot.imshow(data)
pyplot.show()
~~~

<img src="../../novice/python/01-numpy_files/novice/python/01-numpy_71_0.png">
![Heatmap of the Data](fig/01-numpy_71_0.png)

Blue regions in this heat map are low values, while red shows high values.
As we can see,
Expand All @@ -513,7 +513,7 @@ pyplot.plot(ave_inflammation)
pyplot.show()
~~~

<img src="../../novice/python/01-numpy_files/novice/python/01-numpy_73_0.png">
![Average Inflammation Over Time](fig/01-numpy_73_0.png)

Here,
we have put the average per day across all patients in the variable `ave_inflammation`,
Expand All @@ -529,14 +529,14 @@ pyplot.plot(data.max(axis=0))
pyplot.show()
~~~

<img src="../../novice/python/01-numpy_files/novice/python/01-numpy_75_1.png">
![Maximum Value Along The First Axis](fig/01-numpy_75_1.png)

~~~ {.python}
pyplot.plot(data.min(axis=0))
pyplot.show()
~~~

<img src="../../novice/python/01-numpy_files/novice/python/01-numpy_75_3.png">
![Minimum Value Along The First Axis](fig/01-numpy_75_3.png)

The maximum value rises and falls perfectly smoothly,
while the minimum seems to be a step function.
Expand Down Expand Up @@ -572,7 +572,7 @@ plt.tight_layout()
plt.show()
~~~

<img src="../../novice/python/01-numpy_files/novice/python/01-numpy_80_0.png">
![The Previous Plots as Subplots](fig/01-numpy_80_0.png)

The first two lines re-load our libraries as `np` and `plt`,
which are the aliases most Python programmers use.
Expand Down
14 changes: 7 additions & 7 deletions 02-func.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ final = fahr_to_celsius(original)

The diagram below shows what memory looks like after the first line has been executed:

<img src="img/python-call-stack-01.svg" alt="Call Stack (Initial State)" />
![Call Stack (Initial State)](fig/python-call-stack-01.svg)

When we call `fahr_to_celsius`,
Python *doesn't* create the variable `temp` right away.
Expand All @@ -240,12 +240,12 @@ to keep track of the variables defined by `fahr_to_kelvin`.
Initially,
this stack frame only holds the value of `temp`:

<img src="img/python-call-stack-02.svg" alt="Call Stack Immediately After First Function Call" />
![Call Stack Immediately After First Function Call](fig/python-call-stack-02.svg)

When we call `fahr_to_kelvin` inside `fahr_to_celsius`,
Python creates another stack frame to hold `fahr_to_kelvin`'s variables:

<img src="img/python-call-stack-03.svg" alt="Call Stack During First Nested Function Call" />
![Call Stack During First Nested Function Call](fig/python-call-stack-03.svg)

It does this because there are now two variables in play called `temp`:
the parameter to `fahr_to_celsius`,
Expand All @@ -258,26 +258,26 @@ When the call to `fahr_to_kelvin` returns a value,
Python throws away `fahr_to_kelvin`'s stack frame
and creates a new variable in the stack frame for `fahr_to_celsius` to hold the temperature in Kelvin:

<img src="img/python-call-stack-04.svg" alt="Call Stack After Return From First Nested Function Call" />
![Call Stack After Return From First Nested Function Call](fig/python-call-stack-04.svg)

It then calls `kelvin_to_celsius`,
which means it creates a stack frame to hold that function's variables:

<img src="img/python-call-stack-05.svg" alt="Call Stack During Call to Second Nested Function" />
![Call Stack During Call to Second Nested Function](fig/python-call-stack-05.svg)

Once again,
Python throws away that stack frame when `kelvin_to_celsius` is done
and creates the variable `result` in the stack frame for `fahr_to_celsius`:

<img src="img/python-call-stack-06.svg" alt="Call Stack After Second Nested Function Returns" />
![Call Stack After Second Nested Function Returns](fig/python-call-stack-06.svg)

Finally,
when `fahr_to_celsius` is done,
Python throws away *its* stack frame
and puts its result in a new variable called `final`
that lives in the stack frame we started with:

<img src="img/python-call-stack-07.svg" alt="Call Stack After All Functions Have Finished" />
![Call Stack After All Functions Have Finished](fig/python-call-stack-07.svg)

This final stack frame is always there;
it holds the variables we defined outside the functions in our code.
Expand Down
11 changes: 6 additions & 5 deletions 03-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def analyze(filename):
analyze('inflammation-01.csv')
~~~

<img src="../../novice/python/03-loop_files/novice/python/03-loop_2_0.png">
![](fig/03-loop_2_0.png)

We can use it to analyze other data sets one by one:

~~~ {.python}
analyze('inflammation-02.csv')
~~~

<img src="../../novice/python/03-loop_files/novice/python/03-loop_4_0.png">
![](fig/03-loop_4_0.png)

but we have a dozen data sets right now and more on the way.
We want to create plots for all our data sets with a single statement.
Expand Down Expand Up @@ -344,18 +344,19 @@ for f in filenames:
inflammation-01.csv
~~~

<img src="../../novice/python/03-loop_files/novice/python/03-loop_49_1.png">
![](fig/03-loop_49_1.png)

~~~ {.output}
inflammation-02.csv
~~~

<img src="../../novice/python/03-loop_files/novice/python/03-loop_49_3.png">
![](fig/03-loop_49_3.png)

~~~ {.output}
inflammation-03.csv
~~~

<img src="../../novice/python/03-loop_files/novice/python/03-loop_49_5.png">
![](fig/03-loop_49_5.png)

Sure enough,
the maxima of these data sets show exactly the same ramp as the first,
Expand Down
6 changes: 3 additions & 3 deletions 04-cond.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ RGB is an **additive color model**:
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:

<img src="img/color-cube.png" alt="RGB Color Cube" />
![RGB Color Cube](fig/color-cube.png)

An RGB color is an example of a multi-part value:
like a Cartesian coordinate,
Expand Down Expand Up @@ -206,7 +206,7 @@ If the test is false,
the body of the `else` is executed instead.
Only one or the other is ever executed:

<img src="img/python-flowchart-conditional.svg" alt="Executing a Conditional" />
![Executing a Conditional](fig/python-flowchart-conditional.svg)

Conditional statements don't have to include an `else`.
If there isn't one,
Expand Down Expand Up @@ -333,7 +333,7 @@ As the diagram below shows,
the **inner loop** runs from start to finish
each time the **outer loop** runs once:

<img src="img/python-flowchart-nested-loops.svg" alt="Execution of Nested Loops" />
![Execution of Nested Loops](fig/python-flowchart-nested-loops.svg)

We can combine nesting and conditionals to create patterns in an image:

Expand Down
2 changes: 1 addition & 1 deletion 05-defensive.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ The range of each time series is represented as a pair of numbers,
which are the time the interval started and ended.
The output is the largest range that they all include:

<img src="img/python-overlapping-ranges.svg" alt="Overlapping Ranges" />
![Overlapping Ranges](fig/python-overlapping-ranges.svg)

Most novice programmers would solve this problem like this:

Expand Down

0 comments on commit 0875a72

Please sign in to comment.