author | Santosh G. Vattam <vattam.santosh@gmail.com> |
Wed, 28 Oct 2009 14:44:47 +0530 | |
changeset 232 | b9748af050c4 |
parent 219 | f6725f6bee41 |
child 220 | 15306dad3b81 |
permissions | -rw-r--r-- |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
2 |
% Tutorial slides on Python. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
3 |
% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
4 |
% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
5 |
% Copyright (c) 2005-2009, Prabhu Ramachandran |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
6 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
7 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
8 |
\documentclass[compress,14pt]{beamer} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
9 |
% \documentclass[handout]{beamer} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
10 |
% \usepackage{pgfpages} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
11 |
% \pgfpagesuselayout{4 on 1}[a4paper,border, shrink=5mm,landscape] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
12 |
\usepackage{tikz} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
13 |
\newcommand{\hyperlinkmovie}{} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
14 |
%\usepackage{movie15} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
15 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
16 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
17 |
% Note that in presentation mode |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
18 |
% \paperwidth 364.19536pt |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
19 |
% \paperheight 273.14662pt |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
20 |
% h/w = 0.888 |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
21 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
22 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
23 |
\mode<presentation> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
24 |
{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
25 |
\usetheme{Warsaw} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
26 |
%\usetheme{Boadilla} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
27 |
%\usetheme{default} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
28 |
\useoutertheme{split} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
29 |
\setbeamercovered{transparent} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
30 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
31 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
32 |
% To remove navigation symbols |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
33 |
\setbeamertemplate{navigation symbols}{} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
34 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
35 |
\usepackage{amsmath} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
36 |
\usepackage[english]{babel} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
37 |
\usepackage[latin1]{inputenc} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
38 |
\usepackage{times} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
39 |
\usepackage[T1]{fontenc} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
40 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
41 |
% Taken from Fernando's slides. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
42 |
\usepackage{ae,aecompl} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
43 |
\usepackage{mathpazo,courier,euler} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
44 |
\usepackage[scaled=.95]{helvet} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
45 |
\usepackage{pgf} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
46 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
47 |
\definecolor{darkgreen}{rgb}{0,0.5,0} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
48 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
49 |
\usepackage{listings} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
50 |
\lstset{language=Python, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
51 |
basicstyle=\ttfamily\bfseries, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
52 |
commentstyle=\color{red}\itshape, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
53 |
stringstyle=\color{darkgreen}, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
54 |
showstringspaces=false, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
55 |
keywordstyle=\color{blue}\bfseries} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
56 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
57 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
58 |
% My Macros |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
59 |
\setbeamercolor{postit}{bg=yellow,fg=black} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
60 |
\setbeamercolor{emphbar}{bg=blue!20, fg=black} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
61 |
\newcommand{\emphbar}[1] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
62 |
{\begin{beamercolorbox}[rounded=true]{emphbar} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
63 |
{#1} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
64 |
\end{beamercolorbox} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
65 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
66 |
%{\centerline{\fcolorbox{gray!50} {blue!10}{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
67 |
%\begin{minipage}{0.9\linewidth} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
68 |
% {#1} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
69 |
%\end{minipage} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
70 |
% }}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
71 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
72 |
\newcommand{\myemph}[1]{\structure{\emph{#1}}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
73 |
\newcommand{\PythonCode}[1]{\lstinline{#1}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
74 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
75 |
\newcommand{\tvtk}{\texttt{tvtk}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
76 |
\newcommand{\mlab}{\texttt{mlab}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
77 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
78 |
\newcounter{time} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
79 |
\setcounter{time}{0} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
80 |
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\vspace*{0.1in}\tiny \thetime\ m}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
81 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
82 |
\newcommand\BackgroundPicture[1]{% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
83 |
\setbeamertemplate{background}{% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
84 |
\parbox[c][\paperheight]{\paperwidth}{% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
85 |
\vfill \hfill |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
86 |
\hfill \vfill |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
87 |
}}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
88 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
89 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
90 |
% Configuring the theme |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
91 |
%\setbeamercolor{normal text}{fg=white} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
92 |
%\setbeamercolor{background canvas}{bg=black} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
93 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
94 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
95 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
96 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
97 |
% Title page |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
98 |
\title[]{Test Driven Approach} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
99 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
100 |
\author[FOSSEE Team] {FOSSEE} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
101 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
102 |
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
103 |
\date[] {11, October 2009} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
104 |
\date[] % (optional) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
105 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
106 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
107 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
108 |
%\pgfdeclareimage[height=0.75cm]{iitblogo}{iitblogo} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
109 |
%\logo{\pgfuseimage{iitblogo}} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
110 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
111 |
\AtBeginSection[] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
112 |
{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
113 |
\begin{frame}<beamer> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
114 |
\frametitle{Outline} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
115 |
\Large |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
116 |
\tableofcontents[currentsection,currentsubsection] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
117 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
118 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
119 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
120 |
%% Delete this, if you do not want the table of contents to pop up at |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
121 |
%% the beginning of each subsection: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
122 |
\AtBeginSubsection[] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
123 |
{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
124 |
\begin{frame}<beamer> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
125 |
\frametitle{Outline} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
126 |
\tableofcontents[currentsection,currentsubsection] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
127 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
128 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
129 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
130 |
\AtBeginSection[] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
131 |
{ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
132 |
\begin{frame}<beamer> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
133 |
\frametitle{Outline} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
134 |
\tableofcontents[currentsection,currentsubsection] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
135 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
136 |
} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
137 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
138 |
% DOCUMENT STARTS |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
139 |
\begin{document} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
140 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
141 |
\begin{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
142 |
\maketitle |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
143 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
144 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
145 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
146 |
\section{Debugging} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
147 |
\subsection{Errors and Exceptions} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
148 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
149 |
\frametitle{Errors} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
150 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
151 |
>>> while True print 'Hello world' |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
152 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
153 |
\pause |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
154 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
155 |
File "<stdin>", line 1, in ? |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
156 |
while True print 'Hello world' |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
157 |
^ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
158 |
SyntaxError: invalid syntax |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
159 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
160 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
161 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
162 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
163 |
\frametitle{Exceptions} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
164 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
165 |
>>> print spam |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
166 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
167 |
\pause |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
168 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
169 |
Traceback (most recent call last): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
170 |
File "<stdin>", line 1, in <module> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
171 |
NameError: name 'spam' is not defined |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
172 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
173 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
174 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
175 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
176 |
\frametitle{Exceptions} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
177 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
178 |
>>> 1 / 0 |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
179 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
180 |
\pause |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
181 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
182 |
Traceback (most recent call last): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
183 |
File "<stdin>", line 1, in <module> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
184 |
ZeroDivisionError: integer division |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
185 |
or modulo by zero |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
186 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
187 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
188 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
189 |
\subsection{Strategy} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
190 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
191 |
\frametitle{Debugging effectively} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
192 |
\begin{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
193 |
\item \kwrd{print} based strategy |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
194 |
\item Process: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
195 |
\end{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
196 |
\pgfimage[interpolate=true,width=5cm,height=5cm]{DebugginDiagram.png} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
197 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
198 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
199 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
200 |
\frametitle{Debugging effectively} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
201 |
\begin{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
202 |
\item Using \typ{\%debug} in IPython |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
203 |
\end{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
204 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
205 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
206 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
207 |
\frametitle{Debugging in IPython} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
208 |
\small |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
209 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
210 |
In [1]: import mymodule |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
211 |
In [2]: mymodule.test() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
212 |
--------------------------------------------- |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
213 |
NameError Traceback (most recent call last) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
214 |
<ipython console> in <module>() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
215 |
mymodule.py in test() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
216 |
1 def test(): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
217 |
----> 2 print spam |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
218 |
NameError: global name 'spam' is not defined |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
219 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
220 |
In [3]: %debug |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
221 |
> mymodule.py(2)test() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
222 |
0 print spam |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
223 |
ipdb> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
224 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
225 |
\inctime{15} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
226 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
227 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
228 |
\subsection{Exercise} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
229 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
230 |
\frametitle{Debugging: Exercise} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
231 |
\small |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
232 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
233 |
import keyword |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
234 |
f = open('/path/to/file') |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
235 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
236 |
freq = {} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
237 |
for line in f: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
238 |
words = line.split() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
239 |
for word in words: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
240 |
key = word.strip(',.!;?()[]: ') |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
241 |
if keyword.iskeyword(key): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
242 |
value = freq[key] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
243 |
freq[key] = value + 1 |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
244 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
245 |
print freq |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
246 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
247 |
\inctime{10} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
248 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
249 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
250 |
%% \begin{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
251 |
%% \frametitle{Testing} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
252 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
253 |
%% \begin{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
254 |
%% \item Writing tests is really simple! |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
255 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
256 |
%% \item Using nose. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
257 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
258 |
%% \item Example! |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
259 |
%% \end{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
260 |
%% \end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
261 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
262 |
\section{Test Driven Approach} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
263 |
\begin{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
264 |
\frametitle{Need of Testing!} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
265 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
266 |
\begin{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
267 |
\item Quality |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
268 |
\item Regression |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
269 |
\item Documentation |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
270 |
\end{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
271 |
%% \vspace*{0.25in} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
272 |
%% \emphbar{It is to assure that section of code is working as it is supposed to work} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
273 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
274 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
275 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
276 |
\frametitle{Example} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
277 |
\begin{block}{Problem Statement} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
278 |
Write a function to check whether a given input |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
279 |
string is a palindrome. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
280 |
\end{block} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
281 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
282 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
283 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
284 |
\frametitle{Function: palindrome.py} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
285 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
286 |
def is_palindrome(input_str): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
287 |
return input_str == input_str[::-1] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
288 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
289 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
290 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
291 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
292 |
\frametitle{Test for the palindrome: palindrome.py} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
293 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
294 |
from plaindrome import is_palindrome |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
295 |
def test_function_normal_words(): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
296 |
input = "noon" |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
297 |
assert is_palindrome(input) == True |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
298 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
299 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
300 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
301 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
302 |
\frametitle{Running the tests.} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
303 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
304 |
$ nosetests test.py |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
305 |
. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
306 |
---------------------------------------------- |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
307 |
Ran 1 test in 0.001s |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
308 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
309 |
OK |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
310 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
311 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
312 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
313 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
314 |
\frametitle{Exercise: Including new tests.} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
315 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
316 |
def test_function_ignore_cases_words(): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
317 |
input = "Noon" |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
318 |
assert is_palindrome(input) == True |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
319 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
320 |
\vspace*{0.25in} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
321 |
Check\\ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
322 |
\PythonCode{$ nosetests test.py} \\ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
323 |
\begin{block}{Task} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
324 |
Tweak the code to pass this test. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
325 |
\end{block} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
326 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
327 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
328 |
%\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
329 |
% \frametitle{Lets write some test!} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
330 |
%\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
331 |
%#for form of equation y=mx+c |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
332 |
%#given m and c for two equation, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
333 |
%#finding the intersection point. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
334 |
%def intersect(m1,c1,m2,c2): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
335 |
% x = (c2-c1)/(m1-m2) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
336 |
% y = m1*x+c1 |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
337 |
% return (x,y) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
338 |
%\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
339 |
% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
340 |
%Create a simple test for this |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
341 |
% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
342 |
%function which will make it fail. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
343 |
% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
344 |
%\inctime{15} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
345 |
%\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
346 |
% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
347 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
348 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
349 |
\frametitle{Exercise} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
350 |
Based on Euclid's algorithm: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
351 |
\begin{center} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
352 |
$gcd(a,b)=gcd(b,b\%a)$ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
353 |
\end{center} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
354 |
gcd function can be written as: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
355 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
356 |
def gcd(a, b): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
357 |
if a%b == 0: return b |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
358 |
return gcd(b, a%b) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
359 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
360 |
\vspace*{-0.15in} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
361 |
\begin{block}{Task} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
362 |
\begin{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
363 |
\item Write at least |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
364 |
two tests for above mentioned function. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
365 |
\item Write a non recursive implementation |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
366 |
of gcd(), and test it using already |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
367 |
written tests. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
368 |
\end{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
369 |
\end{block} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
370 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
371 |
\inctime{15} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
372 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
373 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
374 |
\end{document} |