From 068745e3068828ef9c13bde6d4476ba811842903 Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Fri, 2 Oct 2009 22:44:57 +0530 Subject: Moved Array Math, Creation slides around; Added time counters. --- day2/session1.tex | 93 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 43 deletions(-) (limited to 'day2') diff --git a/day2/session1.tex b/day2/session1.tex index d8bbecc..91fc3d6 100644 --- a/day2/session1.tex +++ b/day2/session1.tex @@ -158,6 +158,7 @@ array([5, 8, 11, 14]) # apply functions to array. >>> y = sin(x) \end{lstlisting} +\inctime{5} \end{frame} \begin{frame} @@ -196,16 +197,6 @@ dtype('float64') \inctime{10} \end{frame} -\begin{frame} - {More Numpy} - - \begin{itemize} - \item Multi-dimensional arrays - \item Random number generation - \end{itemize} - -\end{frame} - \begin{frame}[fragile] \frametitle{Multi-dimensional arrays} \begin{lstlisting} @@ -222,6 +213,38 @@ array([10,11,12,-1]) \end{lstlisting} \end{frame} +\begin{frame}[fragile] + \frametitle{Array math} + \begin{itemize} + \item Basic \alert{elementwise} math (given two arrays \typ{a, b}): + \typ{+, -, *, /, \%} + \item Inplace operators: \typ{a += b}, or \typ{add(a, b, + a)} etc. + \item Logical operations: \typ{equal (==)}, \typ{not\_equal (!=)}, + \typ{less (<)}, \typ{greater (>)} etc. + \item Trig and other functions: \typ{sin(x), arcsin(x), sinh(x), + exp(x), sqrt(x)} etc. + \item \typ{sum(x, axis=0), product(x, axis=0)} + \item \typ{dot(a, bp)} + \end{itemize} + \inctime{10} +\end{frame} + +\subsection{Array Creation \& Slicing, Striding Arrays} +\begin{frame}[fragile] + \frametitle{Array creation functions} + \begin{itemize} + \item \typ{array(object, dtype=None, \ldots)} + \item \typ{arange(start, stop=None, step=1 \ldots)} + \item \typ{linspace(start, stop, num=50, \ldots)} + \item \typ{ones(shape, dtype=None, \ldots)} + \item \typ{zeros(shape, dtype=float,\ldots)} + \item \typ{identity(n)} + \item \typ{empty(shape, dtype=float,\ldots)} + \item \typ{ones\_like(x)}, + \item \typ{zeros\_like(x)}, \typ{empty\_like(x)} + \end{itemize} +\end{frame} \begin{frame}[fragile] \frametitle{Slicing arrays} @@ -237,6 +260,7 @@ array([[5, 6], array([3, 6, 9]) \end{lstlisting} \end{frame} + \begin{frame}[fragile] \frametitle{Striding arrays} \begin{lstlisting} @@ -248,41 +272,25 @@ array([[1, 3], \end{lstlisting} \end{frame} -\subsection{Array creation } \begin{frame}[fragile] - \frametitle{Array creation functions} - \begin{itemize} - \item \typ{array(object, dtype=None, \ldots)} - \item \typ{arange(start, stop=None, step=1 \ldots)} - \item \typ{linspace(start, stop, num=50, \ldots)} - \item \typ{ones(shape, dtype=None, \ldots)} - \item \typ{zeros(shape, dtype=float,\ldots)} - \item \typ{identity(n)} - \item \typ{empty(shape, dtype=float,\ldots)} - \item \typ{ones\_like(x)}, - \item \typ{zeros\_like(x)}, \typ{empty\_like(x)} - \end{itemize} +\frametitle{Random Numbers} +\begin{lstlisting} +>>> np.random.rand(3,2) +array([[ 0.96276665, 0.77174861], + [ 0.35138557, 0.61462271], + [ 0.16789255, 0.43848811]]) +>>> np.random.randint(1,100) +42 +\end{lstlisting} +\inctime{15} \end{frame} -\subsection{Array math} \begin{frame}[fragile] - \frametitle{Array math} - \begin{itemize} - \item Basic \alert{elementwise} math (given two arrays \typ{a, b}): - \typ{+, -, *, /, \%} - \item Inplace operators: \typ{a += b}, or \typ{add(a, b, - a)} etc. - \item Logical operations: \typ{equal (==)}, \typ{not\_equal (!=)}, - \typ{less (<)}, \typ{greater (>)} etc. - \item Trig and other functions: \typ{sin(x), arcsin(x), sinh(x), - exp(x), sqrt(x)} etc. - \item \typ{sum(x, axis=0), product(x, axis=0)} - \item \typ{dot(a, bp)} - \end{itemize} + \frametitle{Problem set 1.0} +\inctime{15} \end{frame} - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \section{2D Plotting} \subsection{Getting Started} @@ -314,7 +322,7 @@ array([[1, 3], \end{itemize} \end{frame} -\subsection{Playing with lines} +\subsection{Plots - Lines, Labels and Legends} \begin{frame}[fragile] \frametitle{Basic plotting \ldots} \begin{lstlisting} @@ -344,8 +352,6 @@ array([[1, 3], \end{frame} -\subsection{Handling Text} - \begin{frame}[fragile] \frametitle{Legends and Annotation} \begin{lstlisting} @@ -616,8 +622,9 @@ theta = 2*2*pi*r polar(theta, r, color='#ee8d18', lw=3) # the radius of the grid labels setp(ax.thetagridlabels, y=1.075) -title(r"$\theta=4\pi r", fontsize=20) +title(r'$\theta=4\pi r$', fontsize=20) \end{lstlisting} + \end{block} \end{columns} \end{frame} -- cgit