# HG changeset patch # User Puneeth Chaganti # Date 1288972151 -19800 # Node ID c17aa604468a36a5d5af41afe8e5018d914092e9 # Parent 4b3c0d8fffe2f8fe59c7dd7ba6e341726dcc4702 Changes to accessing parts of arrays during recording. diff -r 4b3c0d8fffe2 -r c17aa604468a accessing-pieces-arrays/script.rst --- a/accessing-pieces-arrays/script.rst Fri Nov 05 21:17:10 2010 +0530 +++ b/accessing-pieces-arrays/script.rst Fri Nov 05 21:19:11 2010 +0530 @@ -120,12 +120,11 @@ C[-1] = 0 -Now, how do we access one column of C? As with accessing -individual elements, the column is the second parameter to be -specified (after the comma). The first parameter, is now replaced -with a ``:`` to say, that we want all the elements of that -dimension, instead of one particular element. We access the third -column by +Now, how do we access one column of C? As with accessing individual +elements, the column is the second parameter to be specified (after +the comma). The first parameter, is replaced with a ``:``. This +specifies that we want all the elements of that dimension, instead of +just one particular element. We access the third column by :: @@ -263,11 +262,10 @@ gives the elements [21, 31, 41, 0] -Note that when specifying ranges, if you are starting from or -going up-to the end, the corresponding element may be dropped. So, -in the previous example to obtain [11, 21, 31, 41], we could have -simply said, -:: +Note that when specifying ranges, if you are starting from the +beginning or going up-to the end, the corresponding element may be +dropped. So, in the previous example to obtain [11, 21, 31, 41], we +could have simply said, :: C[:4, 0] @@ -317,7 +315,7 @@ %%5%% Obtain the square in the center of the image. -Following is an exercise that you must do. +Please, pause the video here. Do the exercises and then continue. {{ show slide containing Solution 5 }} @@ -377,7 +375,7 @@ gives the elements [[12, 13, 14], [0, 0, 0]] -Now, that we know how to stride over an image, we can drop +Now, that we know how to stride over an array, we can drop alternate rows and columns out of the image in I. :: @@ -417,5 +415,5 @@ mode: rst indent-tabs-mode: nil sentence-end-double-space: nil - fill-column: 75 + fill-column: 70 End: diff -r 4b3c0d8fffe2 -r c17aa604468a accessing-pieces-arrays/slides.org --- a/accessing-pieces-arrays/slides.org Fri Nov 05 21:17:10 2010 +0530 +++ b/accessing-pieces-arrays/slides.org Fri Nov 05 21:19:11 2010 +0530 @@ -2,7 +2,7 @@ #+LaTeX_CLASS_OPTIONS: [presentation] #+BEAMER_FRAME_LEVEL: 1 -#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} +#+BEAMER_HEADER_EXTRA: \usetheme{Antibes}\usecolortheme{lily}\useoutertheme{infolines}\setbeamercovered{transparent} #+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra) #+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC diff -r 4b3c0d8fffe2 -r c17aa604468a accessing-pieces-arrays/slides.tex --- a/accessing-pieces-arrays/slides.tex Fri Nov 05 21:17:10 2010 +0530 +++ b/accessing-pieces-arrays/slides.tex Fri Nov 05 21:19:11 2010 +0530 @@ -1,4 +1,4 @@ -% Created 2010-10-26 Tue 12:11 +% Created 2010-11-02 Tue 17:47 \documentclass[presentation]{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -8,7 +8,6 @@ \usepackage{float} \usepackage{wrapfig} \usepackage{soul} -\usepackage{t1enc} \usepackage{textcomp} \usepackage{marvosym} \usepackage{wasysym} @@ -28,7 +27,7 @@ \author{FOSSEE} \date{} -\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} +\usetheme{Antibes}\usecolortheme{lily}\useoutertheme{infolines}\setbeamercovered{transparent} \begin{document} \maketitle @@ -57,7 +56,8 @@ \frametitle{Sample Arrays} \label{sec-2} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} In []: A = array([12, 23, 34, 45, 56]) In []: C = array([[11, 12, 13, 14, 15], @@ -65,7 +65,7 @@ [31, 32, 33, 34, 35], [41, 42, 43, 44, 45], [51, 52, 53, 54, 55]]) -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame} \frametitle{Question 1} @@ -77,9 +77,10 @@ \frametitle{Solution 1} \label{sec-4} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} In []: C[:, -1] = 0 -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame} \frametitle{Question 2} @@ -91,9 +92,10 @@ \frametitle{Solution 2} \label{sec-6} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} In []: A[:] = [11, 12, 13, 14, 15] -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame} \frametitle{squares.png} @@ -117,11 +119,12 @@ \frametitle{Solution 3} \label{sec-9} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} In []: C[1, 1:3] In []: C[0:4, 0] In []: C[1:5, 0] -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame} \frametitle{Question 4} @@ -133,9 +136,10 @@ \frametitle{Solution 4} \label{sec-11} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} In []: C[1:3, 2:4] -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame} \frametitle{Question 5} @@ -147,28 +151,31 @@ \frametitle{Solution 5} \label{sec-13} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} In []: imshow(I[75:225, 75:225]) -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{Question 6} \label{sec-14} Obtain the following -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} [[12, 0], [42, 0]] [[12, 13, 14], [0, 0, 0]] -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{Solution 6} \label{sec-15} -\begin{verbatim} +\lstset{language=Python} +\begin{lstlisting} In []: C[::3, 1::3] In []: C[::4, 1:4] -\end{verbatim} +\end{lstlisting} \end{frame} \begin{frame} \frametitle{Summary} @@ -176,7 +183,7 @@ You should now be able to -- \begin{itemize} -\item Manipulate 1D \& Multi dimensional arrays +\item Manipulate single \& multi dimensional arrays \begin{itemize} \item Access and change individual elements