# HG changeset patch # User Anoop Jacob Thomas # Date 1289135219 -19800 # Node ID 36295bb9176676cb53033deeb9875d0789d7dd27 # Parent 4aea9ed0998345e45e457c05199a7c52b531d4b1 Added quickrefs for dictionaries, getting started with arrays, for, matrices, other plots, savefig, using python modules. diff -r 4aea9ed09983 -r 36295bb91766 dictionaries/quickref.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dictionaries/quickref.tex Sun Nov 07 18:36:59 2010 +0530 @@ -0,0 +1,20 @@ +Defining dictionary:\\ +{\ex \lstinline| d = {'k1':'v1', 'k2':'v2'}|} + +Access value using key in dictionary:\\ +{\ex \lstinline| print d['k1']|} + +Add key-value pair to dictionary:\\ +{\ex \lstinline| d['k3'] = 'v3'|} + +Delete key-value from dictionary:\\ +{\ex \lstinline| del d['k1']|} + +Check container-ship of key in dictionary:\\ +{\ex \lstinline| 'k2' in d|} + +List of keys in dictionary:\\ +{\ex \lstinline| d.keys()|} + +List of values in dictionary:\\ +{\ex \lstinline| d.values()|} diff -r 4aea9ed09983 -r 36295bb91766 getting-started-with-arrays/quickref.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getting-started-with-arrays/quickref.tex Sun Nov 07 18:36:59 2010 +0530 @@ -0,0 +1,14 @@ +Creating an array:\\ +{\ex \lstinline| a = array([[1,2,3,4],[5,6,7,8]])|} + +Finding shape of array:\\ +{\ex \lstinline| a.shape|} + +Reshape an array:\\ +{\ex \lstinline| a.reshape(4,2)|} + +Creating identity matrix:\\ +{\ex \lstinline| identity(3)|} + +Creating matrix with all zeros:\\ +{\ex \lstinline| z = zeros((4,2))|} diff -r 4aea9ed09983 -r 36295bb91766 getting-started-with-for/quickref.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/getting-started-with-for/quickref.tex Sun Nov 07 18:36:59 2010 +0530 @@ -0,0 +1,6 @@ +For loop:\\ +{\ex \lstinline| for i in range(1,11,2):|} +{\ex \lstinline| s = s + i|} + +Range function:\\ +{\ex \lstinline| range([start,]stop[,step])|} diff -r 4aea9ed09983 -r 36295bb91766 matrices/quickref.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/matrices/quickref.tex Sun Nov 07 18:36:59 2010 +0530 @@ -0,0 +1,26 @@ +Matrix Multiplication:\\ +{\ex \lstinline| c = dot(a,b)|} + +Transpose of a matrix:\\ +{\ex \lstinline| m.T|} + +Inverse of a matrix:\\ +{\ex \lstinline| im = inv(m)|} + +Frobenius norm of matrix:\\ +{\ex \lstinline| norm(m)|} + +Inverse norm of matrix:\\ +{\ex \lstinline| norm(m, ord=inf)|} + +Determinant of matrix:\\ +{\ex \lstinline| det(m)|} + +Eigen values of matrix:\\ +{\ex \lstinline| eigvals(m)|} + +Eigen vectors of matrix:\\ +{\ex \lstinline| eig(m)[1]|} + +Singular Value Decomposition on matrix m:\\ +{\ex \lstinline| svd(m)|} diff -r 4aea9ed09983 -r 36295bb91766 other-type-of-plots/quickref.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/other-type-of-plots/quickref.tex Sun Nov 07 18:36:59 2010 +0530 @@ -0,0 +1,11 @@ +Creating scatter plot:\\ +{\ex \lstinline| scatter(x, y)|} + +Creating pie chart:\\ +{\ex \lstinline| pie(p, labels=l)|} + +Creating bar chart:\\ +{\ex \lstinline| bar(x, y)|} + +Creating log-log chart:\\ +{\ex \lstinline| loglog(x, y)|} diff -r 4aea9ed09983 -r 36295bb91766 savefig/quickref.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/savefig/quickref.tex Sun Nov 07 18:36:59 2010 +0530 @@ -0,0 +1,5 @@ +Saving a plot(png):\\ +{\ex \lstinline| savefig('filename.png')|} + +Saving a plot(pdf):\\ +{\ex \lstinline| savefig('filename.pdf')|} diff -r 4aea9ed09983 -r 36295bb91766 using python modules/quickref.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/using python modules/quickref.tex Sun Nov 07 18:36:59 2010 +0530 @@ -0,0 +1,16 @@ +Import all definitions to current name-space:\\ +{\ex \lstinline| from scipy import *|} + +Import few definitions to current name-space:\\ +{\ex \lstinline| from scipy import linspace, pi, sin|} + +Import a module as a new name-space:\\ +{\ex \lstinline| import scipy|} + +Few standard python modules:\\ +{\ex \lstinline| Math: math, random|} +{\ex \lstinline| Internet: urllib2, smtplib|} +{\ex \lstinline| System: sys|} +{\ex \lstinline| OS: os|} +{\ex \lstinline| Regular Expression: re|} +{\ex \lstinline| Compression: gzip, zipfile, tarfile|}