Menu

[r8989]: / trunk / py4science / talks / numpy_intro.lyx  Maximize  Restore  History

Download this file

1124 lines (802 with data), 16.4 kB

#LyX 1.5.5 created this file. For more info see http://www.lyx.org/
\lyxformat 276
\begin_document
\begin_header
\textclass beamer
\begin_preamble
% Include only certain frames - this speeds up compilation
% The frames to be included need to be labeled, by using ERT
% as [label=LABELNAME] (no backslashes or {})
%\includeonlyframes{currentt}

% To make a printable handout (one page per frame), pass
% the handout option to the doc class (Layout menu)

% For good fonts in PDFs, use pslatex fonts (Layout menu)

% Colors and symbols
\usepackage{latexsym}
\usepackage{color}

% Display covered items in transparent form (as opposed
% to not showing them at all)
\newcommand{\coveredinvisible}{
    \setbeamercovered{invisible}
}
\newcommand{\coveredvisible}{
    \setbeamercovered{highly dynamic}
}

% Choose default setting here:
\coveredvisible

\newcommand{\ps}{\vspace{-4mm} }

% Theme configuration.  I've basically built a custom theme out of 
% Warsaw, adding infoline and changing the nav. symbol bar

% Warning: the commands below are order-sensitive!

% load the infolines theme, b/c I want the headline Warsaw 
% uses (split), but the footline from infolines.
% In the document body, these will be deactivated for the title and
% turned on later
\useoutertheme{infolines}
% Main theme
\usetheme{Warsaw}
% Adjust the color for the center (title) box to be that of
% infolines, which Warsaw changes
\setbeamercolor*{title in head/foot}{parent=palette secondary}

% Define a minimal set of navigation symbols
\defbeamertemplate*{navigation symbols}{minmal}
{%
  \hbox{%
    \hbox{\insertframenavigationsymbol}
    \hbox{\insertdocnavigationsymbol}
    \hbox{\insertbackfindforwardnavigationsymbol}%
  }%
}
% activate the minimal navbar
\setbeamertemplate{navigation symbols}[minimal]

%%%%% HACK %%%%%
% I started getting errors because LyX is emmitting a color 'none'
% call, which confuses xcolor.  I'm defining 'none' to be black here.
\definecolor{none}{cmyk}{0,0,0,1}
%%%%% /HACK %%%%%
\end_preamble
\options compress
\language english
\inputencoding auto
\font_roman times
\font_sans helvet
\font_typewriter courier
\font_default_family default
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\paperfontsize default
\spacing single
\papersize default
\use_geometry false
\use_amsmath 2
\use_esint 0
\cite_engine basic
\use_bibtopic false
\paperorientation landscape
\secnumdepth 2
\tocdepth 2
\paragraph_separation indent
\defskip medskip
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\author "" 
\author "" 
\end_header

\begin_body

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Standard
Some things to fix in a future version:
\end_layout

\begin_layout Standard
- trim a bit of time
\end_layout

\begin_layout Standard
- add more about ipython and my own python work, reduce that of others
\end_layout

\begin_layout Standard
- add a final python pros/cons, esp.
 the cons part.
 It will make things more balanced.
\end_layout

\begin_layout Standard
- the PDE part repeats a bit the 'python benefits' which were already pounded
 on.
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Standard

% disable the bottom bar for the title and outline pages
\end_layout

\begin_layout Standard

\end_layout

\begin_layout Standard


\backslash
setbeamertemplate{footline}{}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Standard


\backslash
vspace*{-5mm}
\end_layout

\end_inset


\end_layout

\begin_layout Title
NumPy
\begin_inset OptArg
status open

\begin_layout Standard
NumPy
\end_layout

\end_inset


\end_layout

\begin_layout Subtitle
Efficient numerics in Python
\end_layout

\begin_layout Author
Fernando\InsetSpace ~
Pérez
\newline

\family typewriter
\size scriptsize
<Fernando.Perez@berkeley.edu>
\family default
\size default

\newline
John Hunter
\newline

\family typewriter
\size scriptsize
<jdh2358@gmail.com>
\family default
\size default

\begin_inset OptArg
status open

\begin_layout Standard
FP/JDH
\begin_inset Note Note
status collapsed

\begin_layout Standard
This is used by the 'split' footline theme on the left side of the page
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset ERT
status collapsed

\begin_layout Standard


\backslash
vspace{5mm}
\end_layout

\end_inset


\end_layout

\begin_layout Institute
Neuroscience, UC Berkeley
\newline
Tradelink
\begin_inset Note Note
status open

\begin_layout Standard
- Use the 
\backslash
inst command only if there are several affiliations.
\end_layout

\begin_layout Standard
- Keep it simple, no one is interested in your street address.
\end_layout

\end_inset


\begin_inset OptArg
status open

\begin_layout Standard
UC Berkeley/Tradelink
\begin_inset Note Note
status open

\begin_layout Standard
optional, but mostly needed
\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset ERT
status collapsed

\begin_layout Standard


\backslash
vspace{5mm}
\end_layout

\end_inset


\end_layout

\begin_layout Date
Joint Sciences Division, Claremont, CA
\newline
Oct 25, 2008
\begin_inset OptArg
status open

\begin_layout Standard
NCAR, 10/25/08
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Standard
If you have a file called "institution-logo-filename.xxx", where xxx is a
 graphic format that can be processed by latex or pdflatex, resp., then you
 can add a logo by uncommenting the following:
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Standard

%
\backslash
pgfdeclareimage[height=0.5cm]{institution-logo}{institution-logo-filename}
\end_layout

\begin_layout Standard

\end_layout

\begin_layout Standard

%
\backslash
logo{
\backslash
pgfuseimage{institution-logo}}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Standard
The following causes the table of contents to be shown at the beginning
 of every Section.
 Delete this, if you do not want it.
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Standard


\backslash
AtBeginSection[]{
\end_layout

\begin_layout Standard

\end_layout

\begin_layout Standard

  
\backslash
frame<beamer>{ 
\end_layout

\begin_layout Standard

\end_layout

\begin_layout Standard

    
\backslash
frametitle{Outline}
\end_layout

\begin_layout Standard

\end_layout

\begin_layout Standard

    
\backslash
tableofcontents[currentsection]
\end_layout

\begin_layout Standard

\end_layout

\begin_layout Standard

}
\end_layout

\begin_layout Standard

\end_layout

\begin_layout Standard

}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Note Note
status open

\begin_layout Standard
If you wish to uncover everything in a step-wise fashion, uncomment the
 following command:
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Standard

%
\backslash
beamerdefaultoverlayspecification{<+->}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status collapsed

\begin_layout Standard

% reactivate the footline
\end_layout

\begin_layout Standard

\end_layout

\begin_layout Standard

%
\backslash
setbeamertemplate{footline}[infolines theme]
\end_layout

\end_inset


\end_layout

\begin_layout BeginPlainFrame
Python is a general programming language
\end_layout

\begin_layout ExampleBlock
\begin_inset ERT
status collapsed

\begin_layout Standard

<+->{
\end_layout

\begin_layout Standard

\end_layout

\end_inset


\series bold
Flexible and high level
\series default

\begin_inset ERT
status open

\begin_layout Standard

}
\end_layout

\end_inset


\end_layout

\begin_deeper
\begin_layout Itemize
Basic numbers: ints, floats and complex.
\end_layout

\begin_layout Itemize
Lists: 
\end_layout

\begin_deeper
\begin_layout Itemize
flexible containers.
\end_layout

\begin_layout Itemize
can hold any python object.
\end_layout

\begin_layout Itemize
can grow and shrink.
\end_layout

\end_deeper
\begin_layout LyX-Code

\size footnotesize
In [12]: alist=[1,3.5,'hello world',
\end_layout

\begin_layout LyX-Code

\size footnotesize
['a sublist',99]]
\end_layout

\begin_layout LyX-Code

\size footnotesize
In [13]: alist[2] 
\end_layout

\begin_layout LyX-Code

\size footnotesize
Out[13]: 'hello world'
\end_layout

\begin_layout LyX-Code

\size footnotesize
In [14]: alist.append('more')
\end_layout

\begin_layout LyX-Code

\size footnotesize
In [15]: alist 
\end_layout

\begin_layout LyX-Code

\size footnotesize
Out[15]: [1, 3.5, 'hello world', ['a sublist', 99], 'more']
\size default
  
\end_layout

\begin_layout Itemize
math and cmath modules:
\end_layout

\begin_deeper
\begin_layout Itemize
basic functionality (sqrt, ext, sin, cos, etc)
\end_layout

\end_deeper
\end_deeper
\begin_layout BeginPlainFrame
Is it good enough for scientific computing?
\end_layout

\begin_layout AlertBlock
\begin_inset ERT
status open

\begin_layout Standard

{
\end_layout

\end_inset


\series bold
Efficient numerical processing?
\series default

\begin_inset ERT
status open

\begin_layout Standard

}
\end_layout

\end_inset


\end_layout

\begin_deeper
\begin_layout Itemize
Compiler-specific numbers needed: ints (32, 64-bit), floats, etc.
\end_layout

\begin_layout Itemize
Homogeneous arrays of such elements.
\end_layout

\begin_layout Itemize
Easy arithmetic on entire arrays that is efficient.
\end_layout

\begin_layout Itemize
Comprehensive math library to operate on arrays.
\end_layout

\begin_layout Itemize
Common linear algebra support.
\end_layout

\begin_layout Itemize
Needed for:
\end_layout

\begin_deeper
\begin_layout Itemize
Mathematics
\end_layout

\begin_layout Itemize
Image processing
\end_layout

\begin_layout Itemize
Data analysis
\end_layout

\begin_layout Itemize
...
 Just about anything remotely connected to scientific computing.
\end_layout

\end_deeper
\end_deeper
\begin_layout BeginPlainFrame
A tiny bit of history
\end_layout

\begin_layout Standard

\series bold
\color blue
1990s-2004: Numeric
\end_layout

\begin_layout Itemize
Started by Jim Hugunin, MIT grad student.
\end_layout

\begin_layout Itemize
Developed by many: national labs, academia, industry.
\end_layout

\begin_layout Itemize
Fast and light C code.
\end_layout

\begin_layout Itemize
Difficult to maintain and extend.
\end_layout

\begin_layout Standard

\series bold
\color blue
2004: Numarray
\end_layout

\begin_layout Itemize
Perry Greenfield and team (Hubble Space Telescope)
\end_layout

\begin_layout Itemize
Clean codebase, new ideas.
\end_layout

\begin_layout Itemize
Many new features and documentation.
\end_layout

\begin_layout Itemize
Some performace issues lingered
\end_layout

\begin_layout Standard

\series bold
\color blue
2005-future: NumPy: unification effort
\end_layout

\begin_layout Itemize
Led by Travis Oliphant, with Perry's full support.
\end_layout

\begin_layout Itemize
Best of Numeric and Numarray, into a new codebase
\end_layout

\begin_layout Itemize
The whole community rallied behind the effort.
\end_layout

\begin_layout Standard
\align center

\series bold
\size larger
\color green
Today: only NumPy for any new code!
\end_layout

\begin_layout BeginPlainFrame
NumPy: key ideas
\end_layout

\begin_layout Itemize
A flexible, efficient, multidimensional array object.
\end_layout

\begin_layout Itemize
Homogeneous elements
\end_layout

\begin_deeper
\begin_layout Itemize
Supports all native types (ints, floats, etc).
\end_layout

\begin_layout Itemize
Arbitrary user-defined types of fixed size.
\end_layout

\begin_layout Itemize
Arbitrary Python objects can also be stored.
\end_layout

\end_deeper
\begin_layout Itemize
Convenient syntax for high-level operations.
\end_layout

\begin_layout Itemize
Math library that operates on arrays.
\end_layout

\begin_layout Itemize
Basic scientific functionality:
\end_layout

\begin_deeper
\begin_layout Itemize
Linear algebra
\end_layout

\begin_layout Itemize
FFTs
\end_layout

\begin_layout Itemize
Random number generation
\end_layout

\end_deeper
\begin_layout BeginPlainFrame
NumPy: flexible arrays
\end_layout

\begin_layout Itemize
Array is a container of objects 
\begin_inset Quotes eld
\end_inset

of the same kind
\begin_inset Quotes erd
\end_inset

: 
\series bold
\color blue
homogeneous
\series default
\color inherit
.
\end_layout

\begin_layout Itemize
Concept of 
\begin_inset Quotes eld
\end_inset

kind
\begin_inset Quotes erd
\end_inset

 embodied in the data type, or 
\series bold
\color blue
dtype
\series default
\color inherit
.
\end_layout

\begin_layout Itemize
Dtypes 
\series bold
\color blue
can be user-defined
\series default
\color inherit
 to be arbitrarily complex.
\end_layout

\begin_layout Standard
\align center
\begin_inset Graphics
	filename fig/dtype.png
	lyxscale 50
	width 80page%

\end_inset


\end_layout

\begin_layout Standard
Image credit: T.
 Oliphant, Enthought Inc.
\end_layout

\begin_layout BeginPlainFrame
NumPy: indexing
\end_layout

\begin_layout Standard
Image credit: E.
 Jones, Enthought Inc.
\end_layout

\begin_layout Standard
\align center
\begin_inset Graphics
	filename fig/numpy_indexing.pdf
	lyxscale 50
	height 85pheight%
	BoundingBox 0bp 300bp 1000bp 768bp

\end_inset


\end_layout

\begin_layout BeginPlainFrame
NumPy: fancy indexing
\end_layout

\begin_layout Standard
Image credit: E.
 Jones, Enthought Inc.
\end_layout

\begin_layout Standard
\align center
\begin_inset Graphics
	filename fig/numpy_fancy_indexing.pdf
	lyxscale 50
	height 85pheight%
	BoundingBox 0bp 300bp 1024bp 768bp

\end_inset


\end_layout

\begin_layout BeginPlainFrame
NumPy: broadcasting
\end_layout

\begin_layout Standard
Image credit: E.
 Jones, Enthought Inc.
\end_layout

\begin_layout Standard
\align center
\begin_inset ERT
status open

\begin_layout Standard


\backslash
vspace*{-5mm}
\end_layout

\end_inset


\begin_inset Graphics
	filename fig/numpy_broadcasting.pdf
	lyxscale 50
	height 85pheight%
	BoundingBox 0bp 140bp 1024bp 768bp

\end_inset


\end_layout

\begin_layout BeginPlainFrame
SciPy: numerical algorithms galore
\end_layout

\begin_layout Itemize

\series bold
\color blue
linalg
\series default
\color inherit
 : Linear algebra routines (including BLAS/LAPACK)
\end_layout

\begin_layout Itemize

\series bold
\color blue
sparse
\series default
\color inherit
 : Sparse Matrices (including UMFPACK, ARPACK,...)
\end_layout

\begin_layout Itemize

\series bold
\color blue
fftpack
\series default
\color inherit
 : Discrete Fourier Transform algorithms
\end_layout

\begin_layout Itemize

\series bold
\color blue
cluster
\series default
\color inherit
 : Vector Quantization / Kmeans 
\end_layout

\begin_layout Itemize

\series bold
\color blue
odr
\series default
\color inherit
 : Orthogonal Distance Regression 
\end_layout

\begin_layout Itemize

\series bold
\color blue
special
\series default
\color inherit
 : Special Functions (Airy, Bessel, etc).
\end_layout

\begin_layout Itemize

\series bold
\color blue
stats
\series default
\color inherit
 : Statistical Functions 
\end_layout

\begin_layout Itemize

\series bold
\color blue
optimize
\series default
\color inherit
 : Optimization Tools 
\end_layout

\begin_layout Itemize

\series bold
\color blue
maxentropy
\series default
\color inherit
 : Routines for fitting maximum entropy models 
\end_layout

\begin_layout Itemize

\series bold
\color blue
integrate
\series default
\color inherit
 : Numerical Integration routines 
\end_layout

\begin_layout Itemize

\series bold
\color blue
ndimage
\series default
\color inherit
 : n-dimensional image package 
\end_layout

\begin_layout Itemize

\series bold
\color blue
interpolate
\series default
\color inherit
 : Interpolation Tools 
\end_layout

\begin_layout Itemize

\series bold
\color blue
signal
\series default
\color inherit
 : Signal Processing Tools 
\end_layout

\begin_layout Itemize

\series bold
\color blue
io
\series default
\color inherit
 : Data input and output 
\end_layout

\begin_layout EndFrame

\end_layout

\end_body
\end_document
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.