Skip to content

Commit 1dfa78c

Browse files
committed
Finished tutorial. Added pdf.
1 parent 35a2c79 commit 1dfa78c

3 files changed

Lines changed: 37 additions & 41 deletions

File tree

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ docs/_build/
5656
# PyBuilder
5757
target/
5858

59-
# Latex
59+
# LaTeX
6060
*.aux
6161
*.auxlock
6262
*.log
6363
*.nav
6464
*.out
65-
*.pdf
6665
*.snm
6766
*.synctex.gz
6867
*.toc

Python_Tutorial/PythonTutorial.pdf

307 KB
Binary file not shown.

Python_Tutorial/PythonTutorial.tex

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
\documentclass[xcolor=x11names, compress,handout]{beamer}
3+
\documentclass[xcolor=x11names, compress]{beamer}
44

55
%% General document %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66
\usepackage{graphicx}
@@ -261,7 +261,7 @@
261261
{\includegraphics[width=0.7\textwidth]{logo3.png}}\\ \vspace{-10pt}
262262
263263
264-
\ver{pmediano@ic.ac.uk} \hspace{20pt} \ver{m.garnelo@ic.ac.uk}
264+
\ver{pmediano@ic.ac.uk} \hspace{20pt} \ver{garnelo@ic.ac.uk}
265265
\end{center}
266266
\end{frame}
267267
@@ -312,19 +312,11 @@ \subsection{The import system}
312312
\textbf{The import system}
313313
314314
\begin{itemize}
315-
\item Often the definitions (e.g. functions) we want to use might be stored in a different script called \textit{module}.
315+
\item Often the definitions (e.g. functions) we want to use might be stored in a different script, i.e. another \textit{module}.
316316
\item In order to use definitions from other modules we need to import these modules at the beginning of our script.
317-
\item This is done via the command \textit{import}
318-
% \begin{lstlisting}[xleftmargin=.2\textwidth]
319-
% import numpy
320-
% \end{lstlisting}
317+
\item This is done via the \textit{import} command:
321318
\mint{python}@ import numpy@
322-
\item If the name of the module is long we can set a new abbreviation for it
323-
% \begin{lstlisting}[xleftmargin=.2\textwidth]
324-
% import numpy as np
325-
% \end{lstlisting}
326319
\mint{python}@ import numpy as np@
327-
\item We can also load specific definitions:
328320
\begin{minted}{python}
329321
from scipy import *
330322
from matplotlib import pyplot
@@ -340,21 +332,21 @@ \subsection{\scshape Classes}
340332
\begin{frame}[fragile]{Python basics}
341333
\textbf{Classes}
342334
\begin{itemize}
343-
\item Classes are blueprints for creating objects
344-
\item Classes can contain functions that are applied to objects from that class
335+
\item Classes can contain \emph{members} and \emph{methods}.
336+
\item The constructor is the reserved method \verb@__init__@
345337
\end{itemize}
346338
347339
\begin{minted}{python}
348-
class Shape:
349-
def __init__(self, x , y):
350-
self.x = x
351-
self.y = y
340+
class Shape:
341+
def __init__(self, x , y):
342+
self.x = x
343+
self.y = y
352344
353-
def area(self):
354-
return self.x * self.y
345+
def area(self):
346+
return self.x * self.y
355347
356-
rectangle = Shape(100, 45)
357-
print rectangle.area()
348+
rectangle = Shape(100, 45)
349+
print rectangle.area()
358350
\end{minted}
359351
360352
\end{frame}
@@ -381,6 +373,8 @@ \subsection{Indentation}
381373
\item Mind that beginnings of blocks are indicated with a colon ":"
382374
\end{itemize}
383375
376+
\pause
377+
384378
\textbf{0 - indexing}
385379
\begin{itemize}
386380
\item The index of the first element in python is 0
@@ -400,7 +394,6 @@ \section{ \scshape For Matlab Fans}
400394
401395
First piece of advice:
402396
403-
% \vfill
404397
\pause
405398
\vspace{10pt}
406399
@@ -409,7 +402,6 @@ \section{ \scshape For Matlab Fans}
409402
\end{itemize}
410403
411404
\vspace{20pt}
412-
% \btVFill
413405
414406
\begin{figure}[b]
415407
\centering
@@ -480,6 +472,7 @@ \subsection{Data structures}
480472
\end{description}
481473
482474
\vspace{10pt}
475+
\pause
483476
484477
\(
485478
\<{0.6\linewidth}
@@ -508,6 +501,7 @@ \subsection{Data structures}
508501
\)
509502
510503
\vspace{25pt}
504+
\pause
511505
512506
We recommend to use always \textbf{\texttt{np.array}}.
513507
@@ -544,16 +538,20 @@ \subsection{The Question}
544538
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
545539
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
546540
\section{ \scshape Tools}
547-
\subsection{Development environments}
548-
\begin{frame}{Development environments}
541+
\subsection{Development tools}
542+
\begin{frame}{Development tools}
549543
550-
\large
544+
\Large
551545
\begin{itemize}
552-
\item Vim + terminal
553-
\item Spyder
554-
\item Atom
546+
\newcommand{\myitem}{\vfill \pause \item}
547+
\myitem Editor + terminal
548+
\myitem Spyder
549+
\myitem iPython (notebook)
555550
\end{itemize}
556551
552+
\vfill
553+
\pause
554+
557555
Remember to use a debugger! \\
558556
~ ~ $\rightarrow$ \textbf{pdb}
559557
@@ -562,7 +560,7 @@ \subsection{Development environments}
562560
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
563561
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564562
\subsection{Virtual environments and packages}
565-
\begin{frame}{Logistics}
563+
\begin{frame}{Logistics and installation}
566564
567565
\large
568566
@@ -573,12 +571,14 @@ \subsection{Virtual environments and packages}
573571
\item If you still don't have access to the DoC machines, talk with me ASAP!
574572
575573
\vfill
574+
\pause
576575
577576
\item No mortal is allowed to install programs on the DoC machines, so we'll
578577
use Python's \textbf{virtualenv}.
579578
580579
\begin{itemize}
581-
\item A \emph{virtual environment} is a Python island.
580+
\item A \emph{virtual environment} is a small Python bubble.
581+
\vspace{3pt}
582582
\item You can~ \ver{pip install} packages inside without requiring permissions.
583583
\end{itemize}
584584
@@ -592,15 +592,13 @@ \subsection{Virtual environments and packages}
592592
593593
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
594594
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595-
\begin{frame}[fragile]{Virtual environments and new packages}
595+
\begin{frame}[fragile]{Virtual environment}
596596
597597
\begin{itemize}
598598
\item Setting up your \ver{virtualenv}:
599599
\end{itemize}
600+
600601
\begin{minted}[bgcolor=aliceblue]{bash}
601-
cd /vol/bitbucket
602-
mkdir <YOURUSERNAME>
603-
cd <YOURUSERNAME>
604602
virtualenv venv
605603
cd venv
606604
source bin/activate
@@ -613,7 +611,7 @@ \subsection{Virtual environments and packages}
613611
614612
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615613
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
616-
\begin{frame}[fragile]{Virtual environments and new packages}
614+
\begin{frame}[fragile]{Virtual environment}
617615
618616
\begin{itemize}
619617
\item To install Spyder:
@@ -647,7 +645,7 @@ \subsection{Links}
647645
\item NumPy for Matlab users:
648646
649647
\vspace{5pt}
650-
{\scriptsize \centering \url{http://wiki.scipy.org/NumPy_for_Matlab_Users}\\}
648+
{\scriptsize \centering \url{http://mathesaurus.sourceforge.net/matlab-numpy.html}\\}
651649
652650
\vspace{8pt}
653651
\item Using Vim as a Python IDE:
@@ -681,7 +679,6 @@ \section{}
681679
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
682680
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
683681
{
684-
\setbeamercolor{background canvas}{bg=black}
685682
\usebackgroundtemplate{\includegraphics[width=\paperwidth, clip, trim=80 0 80 0]{HolyGrail065}}
686683
\begin{frame}[plain, noframenumbering]
687684
\end{frame}

0 commit comments

Comments
 (0)