ipython - fernando pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 ·...

30
IPython Components for Interactive Scientific Computing Fernando Pérez Brian E. Granger [email protected] [email protected] Helen Wills Neuroscience Instiute, U.C. Berkeley Physics, California Polytechnic State University, San Luis Obispo SIAM CSE 09, Miami March 5, 2009

Upload: others

Post on 18-Jun-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPythonComponents for Interactive Scientific Computing

Fernando PérezBrian E. Granger

[email protected]

[email protected]

Helen Wills Neuroscience Instiute, U.C. BerkeleyPhysics, California Polytechnic State University, San Luis Obispo

SIAM CSE 09, MiamiMarch 5, 2009

Page 2: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 2 / 28

Page 3: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 2 / 28

Page 4: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 2 / 28

Page 5: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

SciComp

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 3 / 28

Page 6: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

SciComp Inherently exploratory

Scientific computingThe computer as a microscope

Problem’s definition evolves as we understand it.No ‘requirements’ to build an application against.Mathematica, Maple, Matlab, IDL, etc.

All have an interactive environment.

Applications Languages

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 4 / 28

Page 7: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

SciComp Python

Python?

Primitive interactive interpreter provided.

Very good introspection.

All entities can be inspected at runtime by the language itself.

Dynamic reloading of (most) code.

Builtin documentation for objects (docstrings).

Live and post-mortem interactive debugging.

Note: Applications can also be built (easier than in C/Fortran).

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 5 / 28

Page 8: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPython

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 6 / 28

Page 9: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPython

What is IPython?

1 A better Python shell: object introspection, system access, ‘magic’command system, . . .

2 An embeddable interpreter: mix batch and interactive work.

3 A flexible component: tweak to taste for your project.

4 An interactive component plug into GUIs, browsers, etc.

5 High level distributed/parallel computing: next talk.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 7 / 28

Page 10: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPython

Quick overview

HistoryStarted in late 2001, ‘just one afternoon’...It seems to have filled a need.Organic community uptake, mostly ‘spare time’.Messy code, good functionalityMany contributions from outsiders

ToolsProject hosting (site, wiki, mailing lists):http://ipython.scipy.org (courtesy of Enthought)Code hosting and bug tracking:http://launchpad.net/ipython (Canonical)Distributed Version control: Bazaar.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 8 / 28

Page 11: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPython

Status

Code structure (as of early 2009):

Language LOC ProportionPython 37323 99.07%

Lisp 262 0.70%Sh 51 0.14%

Objective C 37 0.10%

Data generated using David A. Wheeler’s ‘SLOCCount’

Mailing lists:

Users: ∼400 membersDevelopers:∼170 members

Available on all Linux distributions. We provide OS X andWindows installers.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 9 / 28

Page 12: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPython

Cast of Characters

Brian Granger - Physics, Cal State San Luis ObispoVille Vainio - CS, Tampere University of Technology, FinlandMin Ragan-Kelley - Applied science, UC BerkeleyGael Varoquaux - Neurospin (Orsay, France)Robert Kern - EnthoughtStefan van der Walt - Applied Math, U. Stellenbosch, South AfricaBarry Wark - Neuroscience, U. Washington.Jorgen Stenarson - SwedenOndrej Certik - Physics, U. Nevada RenoLaurent Dufrechou - FranceVivian De Smedt - BelgiumDarren Dale - Astronomy, CornellMany more I am forgetting...

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 10 / 28

Page 13: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Matlab-like interactive usageMatplotlib: high quality plotting. Scipy: numerical algorithms.

Page 14: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Multiple GUI systemsVTK with WxWidgets

Page 15: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPython

Components

Interactive app - terminalEmbeddable shell (dbg, exploration, control)Widget (Wx, GTK, Tk, Qt)Network-aware computational engine

Interactive distributed and parallel computingHigh-level interfaces for thisComplement, not replace MPI

Node for visual-programming driven HPC - IPVision

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 13 / 28

Page 16: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPython

IPython for distributed and parallel computing

Think of Python as ‘the CPU’.IPython abstracts them over the network.Use interactively or not.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 14 / 28

Page 17: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Vision: visual programmingMichel Sanner, Scripps Institute, La Jolla.

Page 18: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

VisionA generic framework for visual programming

Page 19: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPVision: distributed computingWith: Michel Sanner, Jose Unpingco, Ananth Devulapalli [Ohio SupercomputingCenter/OSU], Min Ragan-Kelley [UC Berkeley]

Page 20: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPVision

Easy access to distributed computing for non-expertsVision allows any python library to be accessed (after wrapping)Users get to use all their cores...

Page 21: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

IPython

Part of an ecosystemRapid flow of developments across open source projects

Matplotlib: interactive plotting and GUI support.

Numpy: sharing code for testing support.

Nose: automatic testing system

Sphinx: high quality documentation.

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 19 / 28

Page 22: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Users

Outline

1 Scientific ComputingInherently exploratoryPython?

2 IPython: Interactive Python

3 Users

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 20 / 28

Page 23: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Sympy: symbolic computingOndrej Certik & team, U. Nevada Reno

Page 24: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

BCPy2000: Brain-Computer Interface systemsIntrospection of a multi-module real-time system

Figure credit: BCPy2000 team.

Page 25: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

NS-3 PyViz: discrete event simulationGTK widget inside the application

Figure credit: Gustavo Carneiro, NS-3 PyViz author.

Page 26: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

MayaVi 2: VTK for the rest of usWxWidgets embedded shell

Page 27: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

And the obligatory one: the iPhone

Figure credit: Josh Bloom, UC Berkeley Astronomy.

Page 28: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Others

Sage: open source mathematics

Customized IPython instance (command line).Input preprocessing to extend the language ‘on the fly’

Django, TurboGears, Zope: web frameworks.

PyRAF from the Hubble Telescope.

CASA from NRAO.

Ganga from CERN.

Amazon cloud: run your own IPython instances

as many as you want, without licensing restrictions...

More...

Page 29: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

Users

Wrapup

Interactive, exploratory workflows are natural in scientificcomputing

Python is a great language for this approach

IPython has many tools to support it

Use it in your projects...

let us know of problemsjoin in to make it betteropen source, by scientists, for scientists!

FP/BG (UC Berkeley/CalPoly) Python & Scientific Computing SIAM, 3/5/09 27 / 28

Page 30: IPython - Fernando Pérezfperez.org/py4science/2009_siam_cse/ipython_interact... · 2009-03-09 · IPython Components for Interactive Scientific Computing Fernando Pérez Brian E

http://ipython.scipy.org

Thanks!Any questions?