Skip to content

Commit bd6207a

Browse files
committed
Website build
1 parent 49a52ea commit bd6207a

19 files changed

+589
-304
lines changed

0_introduction.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
and abstraction produce software which is easier to write, easier to
9898
understand, easier to debug and easier to extend. Indeed, as with
9999
abstraction in mathematics, abstraction in coding is a form of
100-
constructive laziness: it simultaniously allows the mathematician to
100+
constructive laziness: it simultaneously allows the mathematician to
101101
achieve more and do less work.</p>
102102
<p>This course is a second course in programming, building a previously
103103
acquired basic understanding of programming in Python. In covering
@@ -125,7 +125,7 @@ <h3><span class="section-number">1.1.1. </span>The notes<a class="headerlink" hr
125125
<p>All of the new material we cover in this course is presented in the notes. They
126126
always the starting point for your work. Each chapter will introduce new
127127
concepts in programming, often tied back to related mathematical concepts, and
128-
always illustraded by practical code examples. Python has excellent <a class="reference external" href="https://docs.python.org/3/">official
128+
always illustrated by practical code examples. Python has excellent <a class="reference external" href="https://docs.python.org/3/">official
129129
online documentation</a>, and we link to that
130130
throughout the text. External links show up in orange while <a class="reference internal" href="#introduction"><span class="std std-ref">internal links
131131
to other parts of the notes</span></a> are red. Sometimes we introduce
@@ -164,14 +164,14 @@ <h3><span class="section-number">1.1.2. </span>The videos<a class="headerlink" h
164164
practice, often by showing live coding sessions. Usually you’ll want to watch
165165
the video for a given section <em>after</em> reading the corresponding notes.</p>
166166
</div>
167-
<div class="section" id="the-quizes">
168-
<h3><span class="section-number">1.1.3. </span>The quizes<a class="headerlink" href="#the-quizes" title="Permalink to this headline"></a></h3>
167+
<div class="section" id="the-quizzes">
168+
<h3><span class="section-number">1.1.3. </span>The quizzes<a class="headerlink" href="#the-quizzes" title="Permalink to this headline"></a></h3>
169169
<p>Towards the end of each chapter is a link back to a quiz on Imperial’s
170-
Blackboard system. The quizes are designed to allow you to convince yourself
170+
Blackboard system. The quizzes are designed to allow you to convince yourself
171171
that you’ve understood the material in the chapter. Sometimes they will simply
172172
be multiple choice questions testing your understanding of the material, but
173173
sometimes you will need to open up Python and try things out in order to work
174-
out the right answer. The quizes do not contribute to your module grade, but how
174+
out the right answer. The quizzes do not contribute to your module grade, but how
175175
well you are doing on them is an indication of your progress on the module.</p>
176176
</div>
177177
<div class="section" id="the-exercises">

1_programs_in_files.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ <h2><span class="section-number">2.7. </span>Testing frameworks<a class="headerl
621621
the practical details of including tests in your code here.</p>
622622
<p>There are a number of Python packages which support code testing. The
623623
concepts are largely similar so rather than get bogged down in the
624-
details of multiple frameworks, we will introduce <a class="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v6.0.1.dev152+g91dbdb60)"><span class="xref std std-doc">pytest</span></a>, which is one of the most widely used.</p>
624+
details of multiple frameworks, we will introduce <a class="reference external" href="https://docs.pytest.org/en/latest/index.html" title="(in pytest v6.0.1.dev168+g4df39e3a)"><span class="xref std std-doc">pytest</span></a>, which is one of the most widely used.</p>
625625
<div class="section" id="pytest-tests">
626626
<h3><span class="section-number">2.7.1. </span>Pytest tests<a class="headerlink" href="#pytest-tests" title="Permalink to this headline"></a></h3>
627627
<p>A Pytest test is simply a function whose name starts with <code class="xref py py-obj docutils literal notranslate"><span class="pre">test_</span></code>. In

4_abstract_data_types.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<div class="body" role="main">
5151

5252
<div class="section" id="abstract-data-types">
53-
<h1><span class="section-number">5. </span>Abstract data types<a class="headerlink" href="#abstract-data-types" title="Permalink to this headline"></a></h1>
53+
<span id="id1"></span><h1><span class="section-number">5. </span>Abstract data types<a class="headerlink" href="#abstract-data-types" title="Permalink to this headline"></a></h1>
5454
<p>In <a class="reference internal" href="2_objects.html#objects"><span class="std std-numref">Section 3</span></a>, we introduced the concept of <a class="reference internal" href="2_objects.html#term-type"><span class="xref std std-term">type</span></a> as an
5555
<a class="reference internal" href="2_objects.html#term-abstraction"><span class="xref std std-term">abstraction</span></a> comprising a set of possible values, and a set of
5656
operations. All types in Python are abstractions in this sense
@@ -59,7 +59,7 @@ <h1><span class="section-number">5. </span>Abstract data types<a class="headerli
5959
define purely mathematical types, distinct from their concrete
6060
realisation in code. Indeed, there are typically multiple possible
6161
concrete realisations of a mathematical idea.</p>
62-
<div class="proof proof-type-definition" id="id2">
62+
<div class="proof proof-type-definition" id="id3">
6363

6464
<div class="proof-title">
6565
<span class="proof-type">Definition 5.1</span>
@@ -72,7 +72,7 @@ <h1><span class="section-number">5. </span>Abstract data types<a class="headerli
7272
</div></div><p>That said, it will frequently be helpful in understanding abstract
7373
data types to refer to the ways in which they might be implemented.</p>
7474
<div class="section" id="stacks">
75-
<span id="id1"></span><h2><span class="section-number">5.1. </span>Stacks<a class="headerlink" href="#stacks" title="Permalink to this headline"></a></h2>
75+
<span id="id2"></span><h2><span class="section-number">5.1. </span>Stacks<a class="headerlink" href="#stacks" title="Permalink to this headline"></a></h2>
7676
<p>Possibly the simplest abstract data type which is not synonymous with
7777
a Python type is the <a class="reference internal" href="#term-stack"><span class="xref std std-term">stack</span></a>. A stack is a sequence of objects
7878
in which only the most recently added object is accessible. The image
@@ -200,9 +200,9 @@ <h3><span class="section-number">5.1.1. </span>An example: reverse Polish notati
200200
calculation, the result of the calculation is on the top of the stack.
201201
<a class="reference internal" href="#rpcalc"><span class="std std-numref">Listing 5.1</span></a> shows <a class="reference internal" href="2_objects.html#term-pseudocode"><span class="xref std std-term">pseudocode</span></a>, for a reverse Polish
202202
calculator.</p>
203-
<div class="literal-block-wrapper docutils container" id="id3">
203+
<div class="literal-block-wrapper docutils container" id="id4">
204204
<span id="rpcalc"></span><div class="code-block-caption"><span class="caption-number">Listing 5.1 </span><span class="caption-text">Pseudocode for a reverse Polish calculator implemented
205-
using a <a class="reference internal" href="#term-stack"><span class="xref std std-term">stack</span></a></span><a class="headerlink" href="#id3" title="Permalink to this code"></a></div>
205+
using a <a class="reference internal" href="#term-stack"><span class="xref std std-term">stack</span></a></span><a class="headerlink" href="#id4" title="Permalink to this code"></a></div>
206206
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">inputs</span><span class="p">:</span>
207207
<span class="k">if</span> <span class="n">item</span> <span class="ow">is</span> <span class="n">number</span><span class="p">:</span>
208208
<span class="n">stack</span><span class="o">.</span><span class="n">push</span><span class="p">(</span><span class="n">number</span><span class="p">)</span>
@@ -218,10 +218,10 @@ <h3><span class="section-number">5.1.1. </span>An example: reverse Polish notati
218218
because <span class="math notranslate nohighlight">\(4\ 2\ -\)</span> means <span class="math notranslate nohighlight">\(4 - 2\)</span>, not <span class="math notranslate nohighlight">\(2 - 4\)</span>.
219219
<a class="reference internal" href="#rptable"><span class="std std-numref">Table 5.1</span></a> Shows how a reverse Polish calculator would evaluate
220220
an arithmetic expression.</p>
221-
<span id="rptable"></span><table class="colwidths-given docutils align-default" id="id4">
221+
<span id="rptable"></span><table class="colwidths-given docutils align-default" id="id5">
222222
<caption><span class="caption-number">Table 5.1 </span><span class="caption-text">Evaluation of the reverse Polish expression
223223
<code class="xref py py-obj docutils literal notranslate"><span class="pre">6</span> <span class="pre">2</span> <span class="pre">/</span> <span class="pre">2</span> <span class="pre">4</span> <span class="pre">**</span> <span class="pre">+</span></code> using a stack
224-
(equivalent to <span class="math notranslate nohighlight">\(6/2 + 2^4 = 3 + 16 = 19\)</span>).</span><a class="headerlink" href="#id4" title="Permalink to this table"></a></caption>
224+
(equivalent to <span class="math notranslate nohighlight">\(6/2 + 2^4 = 3 + 16 = 19\)</span>).</span><a class="headerlink" href="#id5" title="Permalink to this table"></a></caption>
225225
<colgroup>
226226
<col style="width: 46%" />
227227
<col style="width: 15%" />
@@ -274,10 +274,10 @@ <h3><span class="section-number">5.1.2. </span>Implementing stacks in Python<a c
274274
<p>While it is strictly true that Python does not have a stack type, the
275275
<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> class functions as a perfectly good stack. The
276276
relationship between the two is shown in <a class="reference internal" href="#list-stack"><span class="std std-numref">Table 5.2</span></a>.</p>
277-
<span id="list-stack"></span><table class="colwidths-given docutils align-default" id="id5">
277+
<span id="list-stack"></span><table class="colwidths-given docutils align-default" id="id6">
278278
<caption><span class="caption-number">Table 5.2 </span><span class="caption-text">Correspondence between abstract stack operations, and
279279
Python list operations. We assume a list called
280-
<code class="xref py py-obj docutils literal notranslate"><span class="pre">my_list</span></code></span><a class="headerlink" href="#id5" title="Permalink to this table"></a></caption>
280+
<code class="xref py py-obj docutils literal notranslate"><span class="pre">my_list</span></code></span><a class="headerlink" href="#id6" title="Permalink to this table"></a></caption>
281281
<colgroup>
282282
<col style="width: 33%" />
283283
<col style="width: 33%" />
@@ -358,7 +358,7 @@ <h2><span class="section-number">5.3. </span>Algorithmic complexity<a class="hea
358358
optimal algorithmic complexity, expressed in big ‘O’ notation, of
359359
operations on abstract data types will be known. Recall the definition
360360
of big ‘O’:</p>
361-
<div class="proof proof-type-definition" id="id6">
361+
<div class="proof proof-type-definition" id="id7">
362362
<span id="bigo"></span>
363363
<div class="proof-title">
364364
<span class="proof-type">Definition 5.2</span>
@@ -393,10 +393,10 @@ <h2><span class="section-number">5.3. </span>Algorithmic complexity<a class="hea
393393
complexity, which measures the peak memory usage of an algorithm or
394394
data structure.</p>
395395
<div class="badcode docutils container" id="badstack">
396-
<div class="literal-block-wrapper docutils container" id="id7">
396+
<div class="literal-block-wrapper docutils container" id="id8">
397397
<div class="code-block-caption"><span class="caption-number">Listing 5.3 </span><span class="caption-text">A poorly designed stack implementation in which push and pop cost
398398
<span class="math notranslate nohighlight">\(O(n)\)</span> operations, where <span class="math notranslate nohighlight">\(n\)</span> is the current
399-
number of objects on the stack.</span><a class="headerlink" href="#id7" title="Permalink to this code"></a></div>
399+
number of objects on the stack.</span><a class="headerlink" href="#id8" title="Permalink to this code"></a></div>
400400
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">BadStack</span><span class="p">:</span>
401401
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
402402
<span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="p">()</span>
@@ -767,8 +767,8 @@ <h3><span class="section-number">5.4.4. </span>Dictionaries<a class="headerlink"
767767
iteration. <a class="reference internal" href="#iterating-linked-list"><span class="std std-numref">Listing 5.4</span></a> shows the code. The helper
768768
class <code class="xref py py-class docutils literal notranslate"><span class="pre">LinkIterator</span></code> is never seen by the user, it’s just there
769769
to keep track of the iteration.</p>
770-
<div class="literal-block-wrapper docutils container" id="id8">
771-
<span id="iterating-linked-list"></span><div class="code-block-caption"><span class="caption-number">Listing 5.4 </span><span class="caption-text">A simple linked list implementation that supports the iterator protocol.</span><a class="headerlink" href="#id8" title="Permalink to this code"></a></div>
770+
<div class="literal-block-wrapper docutils container" id="id9">
771+
<span id="iterating-linked-list"></span><div class="code-block-caption"><span class="caption-number">Listing 5.4 </span><span class="caption-text">A simple linked list implementation that supports the iterator protocol.</span><a class="headerlink" href="#id9" title="Permalink to this code"></a></div>
772772
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Link</span><span class="p">:</span>
773773
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="nb">next</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
774774
<span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">value</span>

_modules/example_code/euclid.html

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
<!DOCTYPE html>
3+
4+
<html>
5+
<head>
6+
<meta charset="utf-8" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>example_code.euclid &#8212; Object oriented programming in Python for mathematicians 2020.0 documentation</title>
9+
<link rel="stylesheet" href="../../_static/fenics.css" type="text/css" />
10+
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
11+
<link rel="stylesheet" type="text/css" href="../../_static/proof.css" />
12+
<link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
13+
<script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
14+
<script src="../../_static/jquery.js"></script>
15+
<script src="../../_static/underscore.js"></script>
16+
<script src="../../_static/doctools.js"></script>
17+
<script src="../../_static/language_data.js"></script>
18+
<script src="../../_static/proof.js"></script>
19+
<script async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
20+
<link rel="index" title="Index" href="../../genindex.html" />
21+
<link rel="search" title="Search" href="../../search.html" />
22+
<!--[if lte IE 6]>
23+
<link rel="stylesheet" href="../../_static/ie6.css" type="text/css" media="screen" charset="utf-8" />
24+
<![endif]-->
25+
26+
<link rel="stylesheet" href="../../_static/featured.css">
27+
28+
29+
<link rel="shortcut icon" href="../../_static/icon.ico" />
30+
31+
32+
</head><body>
33+
<div class="wrapper">
34+
<a href="../../index.html"><img src="../../_static/banner.png" width="900px" alt="FInAT Project Banner" /></a>
35+
<div id="access">
36+
<div class="menu">
37+
<ul>
38+
<li class="page_item"><a href="https://github.com/finite-element/finite-element-course" title="GitHub">GitHub</a></li>
39+
</ul>
40+
</div><!-- .menu -->
41+
</div><!-- #access -->
42+
</div><!-- #wrapper -->
43+
44+
45+
<div class="document">
46+
<div class="documentwrapper">
47+
<div class="bodywrapper">
48+
<div class="body" role="main">
49+
50+
<h1>Source code for example_code.euclid</h1><div class="highlight"><pre>
51+
<div class="viewcode-block" id="gcd"><a class="viewcode-back" href="../../example_code.html#example_code.euclid.gcd">[docs]</a><span></span><span class="k">def</span> <span class="nf">gcd</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
52+
<span class="sd">&quot;&quot;&quot;Return the greatest common divisor of a and b using a recursive</span>
53+
<span class="sd"> implementation of Euclid&#39;s algorithm.&quot;&quot;&quot;</span>
54+
<span class="k">try</span><span class="p">:</span>
55+
<span class="k">return</span> <span class="n">gcd</span><span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">a</span> <span class="o">%</span> <span class="n">b</span><span class="p">)</span>
56+
<span class="k">except</span> <span class="ne">ZeroDivisionError</span><span class="p">:</span>
57+
<span class="k">return</span> <span class="n">a</span></div>
58+
</pre></div>
59+
60+
<div class="clearer"></div>
61+
</div>
62+
</div>
63+
</div>
64+
<div class="clearer"></div>
65+
</div>
66+
<div class="footer" role="contentinfo">
67+
&#169; Copyright 2019-2020, David A. Ham.
68+
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
69+
</div>
70+
</body>
71+
</html>

0 commit comments

Comments
 (0)