author | Shantanu <shantanu@fossee.in> |
Sat, 31 Oct 2009 01:33:41 +0530 | |
changeset 262 | 9664eddee075 |
parent 256 | a06196a05043 |
child 263 | 8a4a1e5aec85 |
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} |
239
8953675dc056
Added slide numbers.
Puneeth Chaganti <punchagan@fossee.in>
parents:
220
diff
changeset
|
28 |
\useoutertheme{infolines} |
219
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}} |
256
a06196a05043
Added interpolate and loadtxt section to session 5 day 1.
Shantanu <shantanu@fossee.in>
parents:
239
diff
changeset
|
77 |
\newcommand{\typ}[1]{\lstinline{#1}} |
219
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 |
220
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
98 |
\title[]{Debugging and \\Test Driven Approach} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
99 |
|
220
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
100 |
\author[FOSSEE] {FOSSEE} |
219
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} |
256
a06196a05043
Added interpolate and loadtxt section to session 5 day 1.
Shantanu <shantanu@fossee.in>
parents:
239
diff
changeset
|
193 |
\item \typ{print} based strategy |
219
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} |
220
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
196 |
\begin{center} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
197 |
\pgfimage[interpolate=true,width=5cm,height=5cm]{DebugginDiagram.png} |
220
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
198 |
\end{center} |
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
199 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
200 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
201 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
202 |
\frametitle{Debugging effectively} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
203 |
\begin{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
204 |
\item Using \typ{\%debug} in IPython |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
205 |
\end{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
206 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
207 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
208 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
209 |
\frametitle{Debugging in IPython} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
210 |
\small |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
211 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
212 |
In [1]: import mymodule |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
213 |
In [2]: mymodule.test() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
214 |
--------------------------------------------- |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
215 |
NameError Traceback (most recent call last) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
216 |
<ipython console> in <module>() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
217 |
mymodule.py in test() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
218 |
1 def test(): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
219 |
----> 2 print spam |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
220 |
NameError: global name 'spam' is not defined |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
221 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
222 |
In [3]: %debug |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
223 |
> mymodule.py(2)test() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
224 |
0 print spam |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
225 |
ipdb> |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
226 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
227 |
\inctime{15} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
228 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
229 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
230 |
\subsection{Exercise} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
231 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
232 |
\frametitle{Debugging: Exercise} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
233 |
\small |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
234 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
235 |
import keyword |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
236 |
f = open('/path/to/file') |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
237 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
238 |
freq = {} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
239 |
for line in f: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
240 |
words = line.split() |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
241 |
for word in words: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
242 |
key = word.strip(',.!;?()[]: ') |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
243 |
if keyword.iskeyword(key): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
244 |
value = freq[key] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
245 |
freq[key] = value + 1 |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
246 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
247 |
print freq |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
248 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
249 |
\inctime{10} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
250 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
251 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
252 |
%% \begin{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
253 |
%% \frametitle{Testing} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
254 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
255 |
%% \begin{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
256 |
%% \item Writing tests is really simple! |
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 Using nose. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
259 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
260 |
%% \item Example! |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
261 |
%% \end{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
262 |
%% \end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
263 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
264 |
\section{Test Driven Approach} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
265 |
\begin{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
266 |
\frametitle{Need of Testing!} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
267 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
268 |
\begin{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
269 |
\item Quality |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
270 |
\item Regression |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
271 |
\item Documentation |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
272 |
\end{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
273 |
%% \vspace*{0.25in} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
274 |
%% \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
|
275 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
276 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
277 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
278 |
\frametitle{Example} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
279 |
\begin{block}{Problem Statement} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
280 |
Write a function to check whether a given input |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
281 |
string is a palindrome. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
282 |
\end{block} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
283 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
284 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
285 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
286 |
\frametitle{Function: palindrome.py} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
287 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
288 |
def is_palindrome(input_str): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
289 |
return input_str == input_str[::-1] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
290 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
291 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
292 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
293 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
294 |
\frametitle{Test for the palindrome: palindrome.py} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
295 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
296 |
from plaindrome import is_palindrome |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
297 |
def test_function_normal_words(): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
298 |
input = "noon" |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
299 |
assert is_palindrome(input) == True |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
300 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
301 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
302 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
303 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
304 |
\frametitle{Running the tests.} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
305 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
306 |
$ nosetests test.py |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
307 |
. |
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 |
Ran 1 test in 0.001s |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
310 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
311 |
OK |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
312 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
313 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
314 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
315 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
316 |
\frametitle{Exercise: Including new tests.} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
317 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
318 |
def test_function_ignore_cases_words(): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
319 |
input = "Noon" |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
320 |
assert is_palindrome(input) == True |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
321 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
322 |
\vspace*{0.25in} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
323 |
Check\\ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
324 |
\PythonCode{$ nosetests test.py} \\ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
325 |
\begin{block}{Task} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
326 |
Tweak the code to pass this test. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
327 |
\end{block} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
328 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
329 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
330 |
%\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
331 |
% \frametitle{Lets write some test!} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
332 |
%\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
333 |
%#for form of equation y=mx+c |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
334 |
%#given m and c for two equation, |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
335 |
%#finding the intersection point. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
336 |
%def intersect(m1,c1,m2,c2): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
337 |
% x = (c2-c1)/(m1-m2) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
338 |
% y = m1*x+c1 |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
339 |
% return (x,y) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
340 |
%\end{lstlisting} |
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 |
%Create a simple test for this |
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 |
%function which will make it fail. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
345 |
% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
346 |
%\inctime{15} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
347 |
%\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
348 |
% |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
349 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
350 |
\begin{frame}[fragile] |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
351 |
\frametitle{Exercise} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
352 |
Based on Euclid's algorithm: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
353 |
\begin{center} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
354 |
$gcd(a,b)=gcd(b,b\%a)$ |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
355 |
\end{center} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
356 |
gcd function can be written as: |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
357 |
\begin{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
358 |
def gcd(a, b): |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
359 |
if a%b == 0: return b |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
360 |
return gcd(b, a%b) |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
361 |
\end{lstlisting} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
362 |
\vspace*{-0.15in} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
363 |
\begin{block}{Task} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
364 |
\begin{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
365 |
\item Write at least |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
366 |
two tests for above mentioned function. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
367 |
\item Write a non recursive implementation |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
368 |
of gcd(), and test it using already |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
369 |
written tests. |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
370 |
\end{itemize} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
371 |
\end{block} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
372 |
|
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
373 |
\inctime{15} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
374 |
\end{frame} |
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
375 |
|
220
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
376 |
\begin{frame} |
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
377 |
\frametitle{We have learned} |
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
378 |
\begin{itemize} |
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
379 |
\item Following and Resolving Error Messages. |
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
380 |
\item Exceptions. |
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
381 |
\item Approach for Debugging. |
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
382 |
\item Writting and running tests. |
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
383 |
\end{itemize} |
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
384 |
\end{frame} |
15306dad3b81
Corrections to day1 Session1, day2 Session 3 and 4.
Shantanu <shantanu@fossee.in>
parents:
219
diff
changeset
|
385 |
|
219
f6725f6bee41
Session 4, Debugging and Testing.
Shantanu <shantanu@fossee.in>
parents:
diff
changeset
|
386 |
\end{document} |