#LyX 1.4.3 created this file. For more info see http://www.lyx.org/
\lyxformat 245
\begin_document
\begin_header
\textclass amsbook
\begin_preamble
\input{preamble.tex}
\end_preamble
\language english
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\spacing single
\papersize default
\use_geometry true
\use_amsmath 1
\cite_engine basic
\use_bibtopic false
\paperorientation portrait
\leftmargin 1.3in
\topmargin 1in
\rightmargin 1.3in
\bottommargin 1in
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\papercolumns 1
\papersides 2
\paperpagestyle default
\tracking_changes false
\output_changes false
\end_header
\begin_body
\begin_layout Standard
This document contains a set of small problems, drawn from many different
fields, meant to illustrate commonly useful techniques for using Python
in scientific computing.
\end_layout
\begin_layout Standard
All problems are presented in a similar fashion: the task is explained including
any necessary mathematical background and a `code skeleton' is provided
that is meant to serve as a starting point for the solution of the exercise.
In some cases, some example output of the expected solution, figures or
additional hints may be provided as well.
\end_layout
\begin_layout Standard
The accompanying source download for this workbook contains the complete
solutions, which are not part of this document for the sake of brevity.
\end_layout
\begin_layout Standard
For several examples, the provided skeleton contains pre-written tests which
validate the correctness of the expected answers.
When you have completed the exercise successfully, you should be able to
run it from within IPython and see something like this (illustrated using
a trapezoidal rule problem, whose solution is in the file
\family typewriter
trapezoid.py
\family default
):
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Standard
\backslash
begin{lstlisting}
\end_layout
\begin_layout Standard
In [7]: run trapezoid.py
\end_layout
\begin_layout Standard
....
\end_layout
\begin_layout Standard
----------------------------------------------------------------------
\end_layout
\begin_layout Standard
Ran 4 tests in 0.003s
\end_layout
\begin_layout Standard
\end_layout
\begin_layout Standard
OK
\end_layout
\begin_layout Standard
\backslash
end{lstlisting}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
This message tells you that 4 automatic tests were successfully executed.
The idea of including automatic tests in your code is a common one in modern
software development, and Python includes in its standard library two modules
for automatic testing, with slightly different functionality:
\family typewriter
unittest
\family default
and
\family typewriter
doctest
\family default
.
These tests were written using the
\family typewriter
unittest
\family default
system, whose complete documentation can be found here:
\begin_inset LatexCommand \htmlurl{http://docs.python.org/lib/module-unittest.html}
\end_inset
.
\end_layout
\begin_layout Standard
Other exercises will illustrate the use of the
\family typewriter
doctest
\family default
system, since it provides complementary functionality.
\end_layout
\end_body
\end_document