Made changes to script, getting started with arrays, as suggested in internal review.
--- a/getting-started-with-arrays/script.rst Sun Nov 07 01:28:29 2010 +0530
+++ b/getting-started-with-arrays/script.rst Sun Nov 07 15:43:46 2010 +0530
@@ -34,14 +34,15 @@
{{{ switch to next slide, outline slide }}}
-In this tutorial, we will learn about arrays, how to convert a list into an
-array and also why an array is preferred over lists. And array operations.
+In this tutorial, we will learn about arrays, we will learn how to convert
+a list into an array array operations and also why an array is preferred
+over lists.
.. #[Puneeth: Fix the grammar above.]
{{{ switch to next slide on overview of array }}}
-Arrays are homogeneous data structures, unlike lists, arrays cannot have
+Arrays are homogeneous data structures. Unlike lists, arrays cannot have
heterogeneous data elements, that is, it can have only one type of data
type, either all integers, or strings, or float, and not a mix.
@@ -52,7 +53,7 @@
type of data, ....]
Arrays are really fast in mathematical operations when compared to lists,
-it is at least 80 to 100 times faster than lists.
+because of the same type of data in arrays.
.. #[Puneeth: For what size of an array is that the comparison?
@@ -60,8 +61,12 @@
Now let us see how to create arrays.
-I am assuming that you have your IPython interpreter running with the
-``-pylab`` option, so that you have the required modules loaded.
+Run your IPython interpreter with ``-pylab`` option, to load the required
+modules to work with arrays.
+{{{ take terminal and run the following command }}}
+::
+
+ ipython -pylab
.. #[Puneeth: 'I am assuming' doesn't sound right. Ask them to open if it
.. is not open?]
@@ -73,9 +78,12 @@
a1 = array([1,2,3,4])
Notice that here we created a one dimensional array. Also notice the object
-we passed to create an array. Now let us see how to create a two
-dimensional array. Pause here and try to do it yourself before looking at
-the solution.
+we passed to create an array. We passed a list to create an array.
+
+Now let us see how to create a two dimensional array. Pause here and try to
+do it yourself before looking at the solution.
+
+{{{ switch to next slide, creating two dimensional arrays }}}
.. #[Puneeth: I don't think this question can be solved by an average
.. viewer. Questions during the tutorial, should generally be to re-iterate
@@ -85,7 +93,8 @@
.. list, using the ``array`` function. Bring the later section about
.. converting a list, here. A separate section is not necessary, IMHO.]
-This is how we create two dimensional arrays.
+We create two dimensional array by converting a list of lists to an array
+as,
::
@@ -94,7 +103,7 @@
.. #[Puneeth: Again, you could explain a bit about the fact that we are
.. converting a list of lists.]
-Let us see an easy method of creating an array with elements 1 to 8.
+Now let us use ``arange()`` function to create the same array as before.
::
@@ -103,7 +112,7 @@
.. #[Puneeth: say, creating the same array as before. for some time I got
.. confused .]
-And it created a single dimensional array of elements from 1 to 8.
+And we obtained a single dimensional array with elements from 1 to 8.
::
@@ -158,10 +167,9 @@
::
- a1.shape
+ a2.shape
-``a1.shape`` object is a tuple, and since a1 is a single dimensional array,
-it returned a tuple (4,).
+``a2.shape`` object is a tuple, and it returned a tuple (2, 4).
.. #[Puneeth: first show a 2D array, so that it becomes easier to explain.
.. Also, the word ``tuple`` need not be mentioned. ]
@@ -172,6 +180,13 @@
.. #[Puneeth: solution missing.]
+It can be done as,
+::
+
+ a1.shape
+ a3.shape
+ ar.shape
+
{{{ Array can have only a single type of data }}}
.. #[Puneeth: I guess, this whole section can be skipped. If you want to
@@ -214,9 +229,10 @@
.. #[Puneeth: something needs to motivate this. why are we suddenly talking
.. of an identity matrix?]
-An identity matrix is a square matrix in which all the diagonal elements
-are one and rest of the elements zero. We can create an identity matrix
-using the method ``identity()``.
+Now let us see how to create identity matrix, an identity matrix is a
+square matrix in which all the diagonal elements are one and rest of the
+elements zero. We can create an identity matrix using the method
+``identity()``.
The function ``identity()`` takes an integer argument,
@@ -224,7 +240,7 @@
identity(3)
-As you can see the identity method returned a three by three square array
+As you can see the identity method returned a three by three square matrix
with all the diagonal elements as one and the rest of the elements as zero.
.. #[Puneeth: You say array here, matrix there -- it's a bit messed up.
@@ -306,8 +322,8 @@
{{{ switch to next slide, summary slide }}}
So this brings us to the end of this tutorial, in this tutorial we covered
-basics of arrays, how to create an array, converting a list to an array,
-basic array operations etc.
+basics of arrays, learned how to create an array, saw how to convert a list
+to an array, and basic array operations etc.
.. #[Puneeth: s/how to create an array/creating an array]
--- a/getting-started-with-arrays/slides.org Sun Nov 07 01:28:29 2010 +0530
+++ b/getting-started-with-arrays/slides.org Sun Nov 07 15:43:46 2010 +0530
@@ -44,9 +44,12 @@
* Creating Arrays
- Creating a 1-dimensional array
: In []: a1 = array([1, 2, 3, 4])
+ ~[1, 2, 3, 4]~ is a list.
+* Creating two-dimensional array
- Creating a 2-dimensional array
: In []: a2 = array([[1,2,3,4],[5,6,7,8]])
- - Easier method of creating array with consecutive elements.
+ here we convert a list of lists to an array making a 2-d array.
+ - Using ~arange()~ function
: In []: ar = arange(1,9)
* ~reshape()~ method
- To reshape an array
@@ -67,11 +70,11 @@
* ~.shape~ of array
- ~.shape~
To find the shape of the array
- : In []: a1.shape
+ : In []: a2.shape
- ~.shape~
returns a tuple of shape
* Exercise 2
- Find out the shape of the other arrays(a2, a3, ar) that we have created.
+ Find out the shape of the other arrays(a1, a3, ar) that we have created.
* Homogeneous data
- All elements in array should be of same type
: In []: a4 = array([1,2,3,'a string'])
--- a/getting-started-with-arrays/slides.tex Sun Nov 07 01:28:29 2010 +0530
+++ b/getting-started-with-arrays/slides.tex Sun Nov 07 15:43:46 2010 +0530
@@ -1,4 +1,4 @@
-% Created 2010-10-12 Tue 00:20
+% Created 2010-11-07 Sun 15:18
\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
@@ -87,6 +87,12 @@
In []: a1 = array([1, 2, 3, 4])
\end{verbatim}
+ \texttt{[1, 2, 3, 4]} is a list.
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Creating two-dimensional array}
+\label{sec-4}
+
\begin{itemize}
\item Creating a 2-dimensional array
\end{itemize}
@@ -95,6 +101,7 @@
In []: a2 = array([[1,2,3,4],[5,6,7,8]])
\end{verbatim}
+ here we convert a list of lists to an array making a 2-d array.
\begin{itemize}
\item Easier method of creating array with consecutive elements.
\end{itemize}
@@ -105,7 +112,7 @@
\end{frame}
\begin{frame}[fragile]
\frametitle{\texttt{reshape()} method}
-\label{sec-4}
+\label{sec-5}
\begin{itemize}
\item To reshape an array
@@ -119,7 +126,7 @@
\end{frame}
\begin{frame}[fragile]
\frametitle{Creating \texttt{array} from \texttt{list}.}
-\label{sec-5}
+\label{sec-6}
\begin{itemize}
\item \texttt{array()} method accepts list as argument
@@ -137,13 +144,13 @@
\end{frame}
\begin{frame}
\frametitle{Exercise 1}
-\label{sec-6}
+\label{sec-7}
Create a 3-dimensional array of the order (2, 2, 4).
\end{frame}
\begin{frame}[fragile]
\frametitle{\texttt{.shape} of array}
-\label{sec-7}
+\label{sec-8}
\begin{itemize}
\item \texttt{.shape}
@@ -158,13 +165,13 @@
\end{frame}
\begin{frame}
\frametitle{Exercise 2}
-\label{sec-8}
+\label{sec-9}
Find out the shape of the other arrays(a2, a3, ar) that we have created.
\end{frame}
\begin{frame}[fragile]
\frametitle{Homogeneous data}
-\label{sec-9}
+\label{sec-10}
\begin{itemize}
\item All elements in array should be of same type
@@ -176,7 +183,7 @@
\end{frame}
\begin{frame}[fragile]
\frametitle{Implicit type casting}
-\label{sec-10}
+\label{sec-11}
\begin{verbatim}
In []: a4
@@ -186,7 +193,7 @@
\end{frame}
\begin{frame}
\frametitle{\texttt{identity()}, \texttt{zeros()} methods}
-\label{sec-11}
+\label{sec-12}
\begin{itemize}
\item \texttt{identity(n)}
@@ -197,7 +204,7 @@
\end{frame}
\begin{frame}
\frametitle{Learning exercise}
-\label{sec-12}
+\label{sec-13}
\begin{itemize}
\item Find out about
@@ -212,7 +219,7 @@
\end{frame}
\begin{frame}
\frametitle{Array operations}
-\label{sec-13}
+\label{sec-14}
\begin{itemize}
\item \texttt{a1 * 2}
@@ -247,7 +254,7 @@
\end{frame}
\begin{frame}
\frametitle{Summary}
-\label{sec-14}
+\label{sec-15}
In this tutorial we covered,
\begin{itemize}
@@ -259,7 +266,7 @@
\end{frame}
\begin{frame}
\frametitle{Thank you!}
-\label{sec-15}
+\label{sec-16}
\begin{block}{}
\begin{center}