# HG changeset patch # User Santosh G. Vattam # Date 1255070446 -19800 # Node ID b66141a81a9a9ef596d5eb7be6b34877322d056e # Parent 04b620d3f1729e80d7eb69956880584403cfb78b# Parent ec13463306496e99e3bbd88313db640869d4d1ec Merged branches. diff -r 04b620d3f172 -r b66141a81a9a day1/links.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/day1/links.tex Fri Oct 09 12:10:46 2009 +0530 @@ -0,0 +1,22 @@ +\documentclass[12pt]{article} +\title{Links and References} +\author{Asokan Pichai\\Prabhu Ramachandran} +\begin{document} +\maketitle +\begin{itemize} + \item Most referred and trusted material for learning \emph{Python} language is available at \url{http://docs.python.org/tutorial/} + \item ``may be one of the thinnest programming language books on my shelf, but it's also one of the best.'' -- \emph{Slashdot, AccordianGuy, September 8, 2004}- available at \url{http://diveintopython.org/} + \item How to Think Like a Computer Scientist: Learning with Python available at \url{http://www.openbookproject.net/thinkcs/python/english/}\\``The concepts covered here apply to all programming languages and to problem solving in general.'' -- \emph{Guido van Rossum, creator of Python} + \item Some assorted articles related to Python \url{http://effbot.org/zone/index.htm} + \item To read more on strings refer to: \\ \url{http://docs.python.org/library/stdtypes.html#string-methods} + \item For documentation on IPython refer: \\ \url{http://ipython.scipy.org/moin/Documentation} + \item Documentation for Numpy and Scipy is available at: \url{http://docs.scipy.org/doc/} + \item For "recipes" or worked examples of commonly-done tasks in SciPy explore: \url{http://www.scipy.org/Cookbook/} + \item User Guide for Mayavi is the best place to look for Mayavi Documentation, available at: \\ \url{http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/} + \item Explore examples and plots based on matplotlib at \\ \url{http://matplotlib.sourceforge.net/examples/index.html} + \item One stop go for Sage is \url{http://www.sagemath.org/doc/} + \item Central page for all SymPy’s documentation is at \\ \url{http://docs.sympy.org/} + \item For videos from basics to advanced Python check out: \\ \url{http://www.archive.org/search.php?query=scipy09} + +\end{itemize} +\end{document} diff -r 04b620d3f172 -r b66141a81a9a day2/handout.tex --- a/day2/handout.tex Fri Oct 09 12:09:08 2009 +0530 +++ b/day2/handout.tex Fri Oct 09 12:10:46 2009 +0530 @@ -7,6 +7,7 @@ \section{Matrices and Arrays \& 2D Plotting} \subsection{Matrices and Arrays} +\subsubsection{Basic Numpy} \begin{verbatim} # Simple array math example >>> import numpy as np @@ -54,7 +55,10 @@ >>> np.greater(a,4) >>> np.sqrt(a) +\end{verbatim} +\subsubsection{Array Creation} +\begin{verbatim} >>> np.array([2,3,4]) array([2, 3, 4]) @@ -69,7 +73,9 @@ >>>np.ones_like(a) array([[1, 1, 1], [1, 1, 1]]) - +\end{verbatim} +\subsubsection{Slicing, Striding Arrays} +\begin{verbatim} >>> a = np.array([[1,2,3], [4,5,6], [7,8,9]]) >>> a[0,1:3] @@ -87,7 +93,9 @@ [7, 9]]) # Slices are references to the # same memory! - +\end{verbatim} +\subsubsection{Random Numbers} +\begin{verbatim} >>> np.random.rand(3,2) array([[ 0.96276665, 0.77174861], [ 0.35138557, 0.61462271], @@ -96,7 +104,7 @@ 42 \end{verbatim} -\subsection{Problem Set} +\subsubsection{Problem Set} \begin{verbatim} >>> from scipy import misc >>> A=misc.imread(name) @@ -112,6 +120,7 @@ \end{enumerate} \subsection{2D Plotting} +\subsubsection{Basic 2D Plotting} \begin{verbatim} $ ipython -pylab >>> x = linspace(0, 2*pi, 1000) @@ -122,7 +131,9 @@ >>> ylabel(r'sin($\chi$)', color='r') >>> title('Simple figure', fontsize=20) >>> savefig('/tmp/test.eps') - +\end{verbatim} +\subsubsection{Tweaking plots} +\begin{verbatim} # Set properties of objects: >>> l, = plot(x, sin(x)) # Why "l,"? @@ -132,7 +143,10 @@ >>> setp(l) # Print properties. >>> clf() # Clear figure. >>> close() # Close figure. +\end{verbatim} +\subsubsection{Working with text} +\begin{verbatim} >>> w = arange(-2,2,.1) >>> plot(w,exp(-(w*w))*cos) >>> ylabel('$f(\omega)$') @@ -144,7 +158,10 @@ arrowprops=dict( facecolor='black', shrink=0.05)) +\end{verbatim} +\subsubsection{Legends} +\begin{verbatim} >>> x = linspace(0, 2*np.pi, 1000) >>> plot(x, cos(5*x), 'r--', label='cosine') @@ -153,7 +170,10 @@ >>> legend() # Or use: >>> legend(['cosine', 'sine']) +\end{verbatim} +\subsubsection{Multiple figures} +\begin{verbatim} >>> figure(1) >>> plot(x, sin(x)) >>> figure(2) @@ -163,7 +183,7 @@ \end{verbatim} -\subsection{Problem Set} +\subsubsection{Problem Set} \begin{enumerate} \item Write a function that plots any regular n-gon given n. \item Consider the logistic map, $f(x) = kx(1-x)$, plot it for @@ -187,11 +207,12 @@ \begin{verbatim} >>> a = np.arange(4) >>> b = np.arange(5) ->>> a+b +>>> a+b #Does this work? >>> a+3 >>> c=np.array([3]) ->>> a+c ->>> b+c +>>> a+c #Works! +>>> b+c #But how? +>>> a.shape, b.shape, c.shape >>> a = np.arange(4) >>> a+3 diff -r 04b620d3f172 -r b66141a81a9a day2/session1.tex --- a/day2/session1.tex Fri Oct 09 12:09:08 2009 +0530 +++ b/day2/session1.tex Fri Oct 09 12:10:46 2009 +0530 @@ -134,10 +134,8 @@ \item Why? \item What: \begin{itemize} - \item An efficient and powerful array type for various common data - types - \item Abstracts out the most commonly used standard operations on - arrays + \item An efficient and powerful array type for various common data types + \item Abstracts out the most commonly used standard operations on arrays \end{itemize} \end{itemize} \end{frame} @@ -803,4 +801,11 @@ \end{columns} \inctime{20} \end{frame} +\begin{frame}{Summary} + \begin{itemize} + \item Basics of Numpy. + \item Array operations. + \item Plotting in 2D. + \end{itemize} +\end{frame} \end{document} diff -r 04b620d3f172 -r b66141a81a9a day2/session2.tex --- a/day2/session2.tex Fri Oct 09 12:09:08 2009 +0530 +++ b/day2/session2.tex Fri Oct 09 12:10:46 2009 +0530 @@ -124,11 +124,12 @@ \begin{lstlisting} >>> a = np.arange(4) >>> b = np.arange(5) - >>> a+b + >>> a+b #Does this work? >>> a+3 >>> c=np.array([3]) - >>> a+c - >>> b+c + >>> a+c #Works! + >>> b+c #But how? + >>> a.shape, b.shape, c.shape \end{lstlisting} \begin{itemize} \item Enter Broadcasting! @@ -426,8 +427,18 @@ Make a plot of $\frac{dx}{dt}$ vs. $x$. \inctime{30} \end{frame} - - +\begin{frame}{Summary} + \begin{itemize} + \item Advanced NumPy + \item SciPy + \begin{itemize} + \item Linear Algebra + \item Integration + \item Interpolation + \item Signal and Image processing + \end{itemize} + \end{itemize} +\end{frame} \end{document} - Numpy arrays (30 mins) diff -r 04b620d3f172 -r b66141a81a9a day2/session3.tex --- a/day2/session3.tex Fri Oct 09 12:09:08 2009 +0530 +++ b/day2/session3.tex Fri Oct 09 12:10:46 2009 +0530 @@ -194,7 +194,7 @@ \section{Tools at your disposal} -\subsection{Mayavi2.0} +\subsection{Mayavi2} \begin{frame} \frametitle{Introduction to Mayavi} diff -r 04b620d3f172 -r b66141a81a9a day2/tda.tex --- a/day2/tda.tex Fri Oct 09 12:09:08 2009 +0530 +++ b/day2/tda.tex Fri Oct 09 12:10:46 2009 +0530 @@ -261,7 +261,7 @@ \begin{frame}[fragile] \frametitle{Exercise} - Based on Euclid's theorem: + Based on Euclid's algorithm: $gcd(a,b)=gcd(b,b\%a)$\\ gcd function can be written as: \begin{lstlisting} @@ -269,14 +269,15 @@ if a%b == 0: return b return gcd(b, a%b) \end{lstlisting} + \vspace*{-0.15in} \begin{block}{Task} - For given gcd implementation write - at least two tests. - \end{block} - \begin{block}{Task} - Write a non recursive implementation + \begin{itemize} + \item Write at least + two tests for above mentioned function. + \item Write a non recursive implementation of gcd(), and test it using already written tests. + \end{itemize} \end{block} \inctime{15}