The Joy of SciPy, Part I

1,190 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,190
On SlideShare
0
From Embeds
0
Number of Embeds
20
Actions
Shares
0
Downloads
23
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

The Joy of SciPy, Part I

  1. 1. The Joy of SciPy Part I, Dinu GhermanPart II, Dave Kammeyer (not included here) Python Users Berlin Meet-up, 2013-02-14
  2. 2. About…Science… Visualisation Analytics Numbers Data Math Big Data Algorithms Machine Learning … and Python
  3. 3. Science, a Reminder Domains Math Education VisualisationData Models Publication Theory Experiments
  4. 4. From Scientific Python “Components”…Nat. Language Toolkit MatplotlibMol. Modelling Toolkit SymPy Chaco PILBioPython.org NumPy Veusz OpenCVPsychoPy.org Blaze … Scikit-imageAstroPython.org Scikit-learn Stackless Pandas … PyPy PyTables Cython Disco Sphinx Numba ReST (sample) Theano ………
  5. 5. … to IntegratedScientific EnvironmentsLegacy: Py-Distributions: Py-Environments:Mathematica ScientificPython IPython.orgMatlab Enthought, EPD SciPy.orgMaple Anaconda Sagemath.orgMagma Python(x, y) Wakari.io Mathics.org Orange
  6. 6. IPython Shell• Extended Inter- active Python shell • Extensions • Help• Tab completion • History• Multi-line editing • Debugger• Shell access • Bookmarks• Magic functions • DEMO…
  7. 7. IPython Notebook• IPython shell in the browser• Markdown text + executable Python code• JSON container, including output• Literate Programming – finally• Great tutorial experience• Easy to share running code – w/o hassle
  8. 8. IPython Notebook Demo• Tour of the IPython notebook (built-in)• Installing a custom extension• Combined later with Matplotlib demo
  9. 9. IPython Extension Demo • Show object graphs • Reuse a previously written package • Run interactively in the notebook • Notebook: http://nbviewer.ipython.org/4770302/ • Code: https://gist.github.com/deeplook/4731035
  10. 10. Matplotlib• Scientific plots• 2D, 3D, interactive• Smart axes, grids• Beautiful math (TeX)• Widgets, annotations, …• http://matplotlib.org/gallery.html
  11. 11. Matplotlib Demo• Simple plots• Bézier path editor• Magic cube
  12. 12. Conferences• http://conference.scipy.org• https://www.euroscipy.org• http://pydata.org †Videos (e.g. by John Hunter , Fernando Pérez et al.):http://pyvideo.org/category/17/pycon-us-2012
  13. 13. Selected Books
  14. 14. What to take away• Use available Python tools for your scientific domain (trivia)!• Use IPython shell & notebook, Matplotlib – far too powerful to leave to scientists! ;-)• Have fun with science – seriously! http://io9.com/5973726/15+year-old-whiz-kid-has- research-on-dwarf-galaxies-published-in-nature
  15. 15. Questions? Exercise?
  16. 16. ExerciseRun the algorithm below using CPython, Cython, PyPy and Numba andcompare their performance. This is implementing a spigot algorithmby A. Sale, D. Saada, S. Rabinowitz, as mentioned onhttp://mail.python.org/pipermail/edu-sig/2012-December/010721.html.Code: https://gist.github.com/deeplook/4947835.def pi_digits(n): "Generate n digits of Pi." k, a, b, a1, b1 = 2, 4, 1, 12, 4 while n > 0: p, q, k = k * k, 2 * k + 1, k + 1 a, b, a1, b1 = a1, b1, p * a + q * a1, p * b + q * b1 d, d1 = a / b, a1 / b1 while d == d1 and n > 0: yield int(d) n -= 1 a, a1 = 10 * (a % b), 10 * (a1 % b1) d, d1 = a / b, a1 / b1>>> list(pi_digits(20))[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4]

×