Skip to content

Commit f8ffa80

Browse files
committed
plausible first draft!!!!
1 parent d0124e8 commit f8ffa80

8 files changed

+120
-54
lines changed

‎doc/source/10_further_object-oriented_features.rst

+16-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Decorators
2020
<https://imperial.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=f1d61410-4200-42e5-92c4-acf2011de8ab>`__.
2121

2222

23-
In :numref:`Week %s <trees>` we encountered the
23+
In :numref:`Chapter %s <trees>` we encountered the
2424
:func:`functools.singledispatch` decorator, which turns a function into a
2525
:term:`single dispatch function`. More generally, a decorator is a function
2626
which takes in a function and returns another function. In other words, the
@@ -246,7 +246,7 @@ access features that it provides.
246246
Abstract methods
247247
~~~~~~~~~~~~~~~~
248248

249-
Let's look back at the groups example from :numref:`Week %s <inheritance>`. We
249+
Let's look back at the groups example from :numref:`Chapter %s <inheritance>`. We
250250
defined the base :class:`~example_code.groups.Group` class and specified that
251251
child classes had to implement the :meth:`_validate` and :meth:`operator`
252252
methods as well as the :attr:`symbol` :term:`class attribute`. But how should
@@ -564,12 +564,19 @@ Glossary
564564
its definition, but which is instead claimed as a subclass by the
565565
superclass.
566566

567-
568567
Exercises
569568
---------
570569

571-
Obtain the `skeleton code for these exercises from GitHub classroom
572-
<https://classroom.github.com/a/qTArFlxP>`__.
570+
.. only:: not book
571+
572+
Using the information on the `book website
573+
<https://object-oriented-programming.github.io/edition1/exercises.html>`__
574+
obtain the skeleton code for these exercises.
575+
576+
.. only:: book
577+
578+
Using the information on the book website [#exercise_page]_ obtain the
579+
skeleton code for these exercises.
573580

574581
.. proof:exercise::
575582
@@ -604,4 +611,7 @@ Obtain the `skeleton code for these exercises from GitHub classroom
604611

605612
.. [#python_in_python] Most of the :ref:`Python Standard Library <library-index>` is written
606613
in Python, so diving in and reading the source code is often an option if
607-
you really want to know how some part of the language works.
614+
you really want to know how some part of the language works.
615+
616+
.. [#exercise_page] `https://object-oriented-programming.github.io/edition1/exercises.html
617+
<https://object-oriented-programming.github.io/edition1/exercises.html>`__

‎doc/source/1_introduction.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Python you use.
134134
which were introduced in Python 3.6, so the code will not work in earlier
135135
versions of Python.
136136

137-
.. _venv:
137+
.. _create_venv:
138138

139139
Setting up a Python virtual environment
140140
---------------------------------------

‎doc/source/2_programs_in_files.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -922,12 +922,14 @@ Glossary
922922
A text file containing a sequence of Python statements to be
923923
executed. In Python, program and script are synonymous.
924924

925+
.. _programs_in_files_exercises:
926+
925927
Exercises
926928
---------
927929

928930
Before attempting the exercises, ensure that you have obtained the software
929931
tools described in :numref:`tools` and set up a working folder and
930-
:term:`virtual environment` as described in :numref:`venv`. If you're not
932+
:term:`virtual environment` as described in :numref:`create_venv`. If you're not
931933
already familiar with Git and GitHub then you will also need to work through
932934
:numref:`Appendix %s <git>` to learn enough to do the exercises.
933935

‎doc/source/6_exceptions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ level of code either typed directly into iPython or executed in a
195195
script. However, what happens if an error occurs in a function call or
196196
even several functions down? Consider the following code, which uses
197197
the :class:`~polynomial.Polynomial` class from
198-
:numref:`chapter %s <objects>`:
198+
:numref:`Chapter %s <objects>`:
199199

200200
.. code-block:: ipython3
201201

‎doc/source/7_inheritance.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ability to make a complex object or operation out of several components. We can
1818
compose objects by simply making one object a :term:`attribute` of another
1919
object. This combines objects in a *has a* relationship. For example the
2020
:class:`~example_code.polynomial.Polynomial` class introduced in
21-
:numref:`chapter %s <objects>` *has a* :class:`tuple` of coefficients. Object
21+
:numref:`Chapter %s <objects>` *has a* :class:`tuple` of coefficients. Object
2222
composition of this sort is a core part of :term:`encapsulation`.
2323

2424
Another way of composing abstractions is to make a new :term:`class`
@@ -808,9 +808,9 @@ Exercises
808808
.. hint::
809809

810810
You will need to :keyword:`import` :class:`example_code.groups.Group`
811-
from the `object_oriented_programming` repository that you installed
812-
:ref:`in Chapter 2 <course_repo>`. You should also `git pull` in that
813-
repository in order to get any changes that have happened in the
811+
from the `object_oriented_programming` repository that you installed in
812+
:numref:`programs_in_files_exercises`. You should also `git pull` in
813+
that repository in order to get any changes that have happened in the
814814
intervening period.
815815

816816
.. hint::

‎doc/source/8_debugging.rst

+65-29
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Debugging and testing
55

66
In :numref:`Chapter %s <errors_and_exceptions>` we learned about
77
:term:`exceptions <exception>` and how to read the :term:`traceback` that is
8-
printed when an unhandled exception is raised. This week we will look at other
8+
printed when an unhandled exception is raised. In this chapter we will look at other
99
tools and techniques that we can use to understand what is wrong with a piece
1010
of code, and therefore how to fix it. Before we do that, we'll divert just
1111
briefly to introduce an important Python module that we'll use in a lot of the
@@ -84,7 +84,7 @@ Observe that the :class:`~pandas.DataFrame` acts as a dictionary of
8484
one-dimensional data :class:`~pandas.Series`. A :class:`pandas.Series` can be
8585
indexed and sliced like any other Python :ref:`sequence type <typesseq>`. This
8686
very high level introduction is all we'll need to use pandas in demonstrations
87-
this week. Much more documentation is available on the `pandas website <https://pandas.pydata.org/docs/>`__.
87+
in this chapter. Much more documentation is available on the `pandas website <https://pandas.pydata.org/docs/>`__.
8888

8989
.. note::
9090

@@ -120,7 +120,7 @@ advantage that integrates well with IPython. Another advanced command-line
120120
debugger is `pdb++
121121
<https://github.com/pdbpp/pdbpp#pdb-a-drop-in-replacement-for-pdb>`__. The
122122
distinct advantage of pdb++ is that it replaces the built-in pdb. Among other
123-
things, this means it can be triggered from a failed `pytest
123+
things, this means it can be triggered from a failed `Pytest
124124
<https://docs.pytest.org/en/stable/>`__ test.
125125

126126
The alternative to a command-line debugger is to use a graphical debugger
@@ -650,15 +650,15 @@ and fails if it is.
650650
Creating a test command
651651
~~~~~~~~~~~~~~~~~~~~~~~
652652

653-
Since pytest provides a framework for creating programs which succeed or fail,
653+
Since Pytest provides a framework for creating programs which succeed or fail,
654654
one approach is write the test that we wish had existed at the time the bug
655655
slipped into our code. The bisection search effectively enables us to
656656
retrospectively introduce this test into our repository. Because we're going to
657657
be rolling back the state of our repository to before we created this command,
658658
this is one exception to the rule that you must always commit all of your work
659659
to the git repository. Make a copy of this command (for example the Python file
660-
containing the pytest test) outside your repository. For the rest of this
661-
section, we'll assume that you've created a pytest test in a file called
660+
containing the Pytest test) outside your repository. For the rest of this
661+
section, we'll assume that you've created a Pytest test in a file called
662662
:file:`bug_test.py` which you have placed in the folder containing your
663663
repository (if you followed the instructions in :numref:`Chapter %s
664664
<programs_files>` then this folder might be called
@@ -830,49 +830,85 @@ Glossary
830830
Exercises
831831
---------
832832

833-
The exercises work a little differently this week, because the objective is not
834-
to write code but to practice debugging techniques. The quiz is not on
835-
BlackBoard but is instead a Google form, because that offers instant feedback.
836-
You should work through the the exercises and quiz together. For most of exercises,
837-
there are quiz questions which you will be able to answer if you are
838-
successfully able to do the exercise.
833+
.. only:: not book
839834

840-
Obtain the `skeleton code for these exercises from GitHub classroom
841-
<https://classroom.github.com/a/mi6I-jcG>`__.
835+
The exercises work a little differently this week, because the objective is
836+
not to write code but to practice debugging techniques. The information on
837+
the `book website
838+
<https://object-oriented-programming.github.io/edition1/exercises.html>`__
839+
points not just to the skeleton code but also to an online quiz which will
840+
provide instant feedback on the questions below. You should access the
841+
skeleton code and then work through the quiz questions.
842842

843-
.. panels::
844-
:card: quiz shadow
843+
.. only:: book
845844

846-
.. link-button:: https://forms.gle/cL5eZycNC9Js19uL7
847-
:text: This week's quiz
848-
:classes: stretched-link
845+
The exercises work a little differently this week, because the objective is
846+
not to write code but to practice debugging techniques. The information on
847+
the book website [#exercise_page]_
848+
points not just to the skeleton code but also to an online quiz which will
849+
provide instant feedback on the questions below. You should access the
850+
skeleton code and then work through exercises, using the online quiz to
851+
check your answers.
849852

850853
.. proof:exercise:: Debugging python code
851854
852855
The skeleton code contains a Python script :file:`scripts/tests_report`.
853-
Run this script under the Visual Studio code debugger and answer the quiz
854-
questions about what you find.
856+
Run this script under the Visual Studio code debugger and answer the
857+
following questions about what you find. Entering the answers into the
858+
online quiz will tell you if you are correct.
859+
860+
1. On which line of the file does the exception occur?
861+
2. How many stack frames are there on the call stack when the exception occurs?
862+
3. What is the exact value of the variable t?
855863

856864
.. proof:exercise:: Minimal failing example
857865
858866
In the file :file:`scripts/tests_report_mfe.py` construct a :term:`minimal failing
859867
example` which exhibits the error you discovered in the previous section.
860868
Your minimal failing example should contain one import and one other line
861-
of code. :file:`tests/test_mfe.py` is a pytest test for this exercise.
869+
of code. :file:`tests/test_mfe.py` is a Pytest test for this exercise.
870+
871+
.. only:: book
872+
873+
.. raw:: latex
874+
875+
\clearpage
862876

863877
.. proof:exercise:: Bisection
864878
865-
The Unified Form Language (UFL) is a computer symbolic algebra package used to
866-
represent partial differential equations in software applying a numerical
867-
technique called the finite element method. Clone the `course fork of the
868-
UFL repository <https://github.com/object-oriented-python/ufl>`__. At some
869-
point in the past, the following code worked:
879+
.. only:: not book
880+
881+
The Unified Form Language (UFL) is a computer symbolic algebra package
882+
used to represent partial differential equations in software applying a
883+
numerical technique called the finite element method. Clone the `course
884+
fork of the UFL repository
885+
<https://github.com/object-oriented-python/ufl>`__. At some point in
886+
the past, the following code worked:
887+
888+
.. only:: book
889+
890+
The Unified Form Language (UFL) is a computer symbolic algebra package
891+
used to represent partial differential equations in software applying a
892+
numerical technique called the finite element method. Clone the course
893+
fork of the UFL repository [#ufl]_. At some point in
894+
the past, the following code worked:
870895

871896
.. code-block:: python3
872897
873898
import ufl
874899
argyris = ufl.FiniteElement("Argyris", degree=6, cell=ufl.triangle)
875900
876901
Use `git bisect` to identify the first commit at which this code failed,
877-
and the last commit at which it worked, and answer the corresponding quiz
878-
questions.
902+
and the last commit at which it worked, and answer the following questions.
903+
The online quiz will tell you if you are correct.
904+
905+
1. What is the commit ID of the first bad commit?
906+
2. What is the commit ID of the last good commit?
907+
908+
.. rubric:: Footnotes
909+
910+
.. [#ufl] `https://github.com/object-oriented-python/ufl
911+
<https://github.com/object-oriented-python/ufl>`__
912+
913+
.. [#exercise_page] `https://object-oriented-programming.github.io/edition1/exercises.html
914+
<https://object-oriented-programming.github.io/edition1/exercises.html>`__

‎doc/source/9_trees_and_directed_acyclic_graphs.rst

+25-6
Original file line numberDiff line numberDiff line change
@@ -1176,19 +1176,35 @@ Glossary
11761176
:func:`functools.singledispatch` function facilitates the creation of
11771177
single dispatch functions.
11781178

1179+
.. only:: book
1180+
1181+
.. raw:: latex
1182+
1183+
\clearpage
1184+
11791185
Exercises
11801186
---------
11811187

1182-
Obtain the `skeleton code for these exercises from GitHub classroom
1183-
<https://classroom.github.com/a/DVDJ8r1y>`__. You should also update your clone
1184-
of the course repository to ensure you have the latest version of the
1185-
:mod:`example_code` package.
1188+
.. only:: not book
1189+
1190+
Using the information on the `book website
1191+
<https://object-oriented-programming.github.io/edition1/exercises.html>`__
1192+
obtain the skeleton code for these exercises. The exercises also make use
1193+
of the book repository which you installed in :ref:`in Chapter 2
1194+
<course_repo>`.
1195+
1196+
.. only:: book
1197+
1198+
Using the information on the book website [#exercise_page]_ obtain the
1199+
skeleton code for these exercises. The exercises also make use
1200+
of the book repository which you installed in
1201+
:numref:`programs_in_files_exercises`.
11861202

11871203
.. _ex_expr:
11881204

11891205
.. proof:exercise::
11901206
1191-
In the skeleton repository for this week, create a :term:`package`
1207+
In the exercise repository, create a :term:`package`
11921208
:mod:`expressions` which implements the class hierarchy in
11931209
:numref:`expr_hierarchy`. When implementing :meth:`~object.__str__`, use the
11941210
symbols `+`, `-`, `*`, `/`, and `^`. The names :class:`Symbol`,
@@ -1233,4 +1249,7 @@ of the course repository to ensure you have the latest version of the
12331249
argument, typically the first. Multiple dispatch, in which the function
12341250
implementation is chosen on the basis of multiple function arguments, is
12351251
also possible, and is a key feature of `the Julia programming language
1236-
<https://julialang.org>`_.
1252+
<https://julialang.org>`_.
1253+
1254+
.. [#exercise_page] `https://object-oriented-programming.github.io/edition1/exercises.html
1255+
<https://object-oriented-programming.github.io/edition1/exercises.html>`__

‎doc/source/a2_git.rst

+5-6
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ button marked :kbd:`Create repository from template`.
350350

351351
.. image:: images/github_template.png
352352

353+
.. only:: book
354+
355+
.. raw:: latex
356+
357+
\clearpage
353358

354359
.. _exercise_instructions:
355360

@@ -365,12 +370,6 @@ this:
365370

366371
.. image:: images/git_exercise.png
367372

368-
.. only:: book
369-
370-
.. raw:: latex
371-
372-
\clearpage
373-
374373
So what we have to do is:
375374

376375
1. Edit `exercise.txt` to replace "Hello World" with "Hello Mars!"

0 commit comments

Comments
 (0)