SlideShare a Scribd company logo
The Joy of SciPy

            Part I, Dinu Gherman
Part II, Dave Kammeyer (not included here)

          Python Users Berlin
          Meet-up, 2013-02-14
About…
Science…
                       Visualisation
           Analytics
                            Numbers
    Data
                 Math
   Big Data               Algorithms

       Machine Learning

                               … and Python
Science, a Reminder
             Domains
  Math                               Education

                     Visualisation
Data
         Models                  Publication

 Theory
                  Experiments
From Scientific
 Python “Components”…
Nat. Language Toolkit                Matplotlib
Mol. Modelling Toolkit      SymPy    Chaco         PIL
BioPython.org               NumPy    Veusz         OpenCV
PsychoPy.org                Blaze    …             Scikit-image
AstroPython.org
                                    Scikit-learn
      Stackless          Pandas     …
      PyPy               PyTables
      Cython             Disco                Sphinx
      Numba                                   ReST (sample)
      Theano                ………
… to Integrated
Scientific Environments
Legacy:       Py-Distributions:   Py-Environments:
Mathematica   ScientificPython     IPython.org
Matlab        Enthought, EPD      SciPy.org
Maple         Anaconda            Sagemath.org
Magma         Python(x, y)        Wakari.io
                                  Mathics.org
                                  Orange
IPython Shell
• Extended Inter-
  active Python shell
                        • Extensions
                        • Help
• Tab completion
                        • History
• Multi-line editing
                        • Debugger
• Shell access
                        • Bookmarks
• Magic functions
                        • DEMO…
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
IPython Notebook
         Demo

• Tour of the IPython notebook (built-in)
• Installing a custom extension
• Combined later with Matplotlib demo
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
Matplotlib
• Scientific plots
• 2D, 3D, interactive
• Smart axes, grids
• Beautiful math (TeX)
• Widgets, annotations, …
• http://matplotlib.org/gallery.html
Matplotlib Demo
• Simple plots
• Bézier path editor
• Magic cube
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
Selected Books
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
Questions?
 Exercise?
Exercise
Run the algorithm below using CPython, Cython, PyPy and Numba and
compare their performance. This is implementing a spigot algorithm
by A. Sale, D. Saada, S. Rabinowitz, as mentioned on
http://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]

More Related Content

PDF
The Joy of SciPy
PDF
Python NumPy Tutorial | NumPy Array | Edureka
PDF
Python and Machine Learning - BCN Python Meetup - 25th Sep 2014
PDF
PyTorch for Deep Learning Practitioners
PDF
Scientific Python
PDF
Marsface Project: Detecting Pseudo-artificial Structures on Mars
PDF
Deep Learning for Image Recognition in Python
PDF
Deep Learning with PyTorch
The Joy of SciPy
Python NumPy Tutorial | NumPy Array | Edureka
Python and Machine Learning - BCN Python Meetup - 25th Sep 2014
PyTorch for Deep Learning Practitioners
Scientific Python
Marsface Project: Detecting Pseudo-artificial Structures on Mars
Deep Learning for Image Recognition in Python
Deep Learning with PyTorch

What's hot (20)

PDF
Pycon2013 : Application of Python in Robotics
PDF
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
PDF
TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...
PPTX
TensorFlow Object Detection API
PPTX
Transfer learning, active learning using tensorflow object detection api
PDF
Pytorch for tf_developers
PDF
Use the Matplotlib, Luke @ PyCon Taiwan 2012
PPTX
PyTorch Tutorial for NTU Machine Learing Course 2017
PPTX
Python Scipy Numpy
PDF
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
ODP
Tensorflow for Beginners
PPTX
Tensorflow windows installation
PPTX
Introduction to PyTorch
PPTX
Introduction to Tensorflow
PDF
On the Necessity and Inapplicability of Python
PDF
On the necessity and inapplicability of python
PDF
Introduction to TensorFlow 2.0
PPT
NATURAL OBJECT ORIENTED PROGRAMMING USING ELICA
Pycon2013 : Application of Python in Robotics
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
TensorFlow Object Detection | Realtime Object Detection with TensorFlow | Ten...
TensorFlow Object Detection API
Transfer learning, active learning using tensorflow object detection api
Pytorch for tf_developers
Use the Matplotlib, Luke @ PyCon Taiwan 2012
PyTorch Tutorial for NTU Machine Learing Course 2017
Python Scipy Numpy
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
Tensorflow for Beginners
Tensorflow windows installation
Introduction to PyTorch
Introduction to Tensorflow
On the Necessity and Inapplicability of Python
On the necessity and inapplicability of python
Introduction to TensorFlow 2.0
NATURAL OBJECT ORIENTED PROGRAMMING USING ELICA
Ad

Viewers also liked (7)

PDF
Twittori - Twittwoch Berlin
PDF
Hipster PDA, A4, Filofax Pocket
PDF
Sociocracy
PDF
Plastic kills - Labels
PDF
Plastik tötet - Aufkleber
PDF
Sociocracy 3.0 a brief introduction (presentation) (v2016-01-29)
PPTX
Writing your bio on Kloodle
Twittori - Twittwoch Berlin
Hipster PDA, A4, Filofax Pocket
Sociocracy
Plastic kills - Labels
Plastik tötet - Aufkleber
Sociocracy 3.0 a brief introduction (presentation) (v2016-01-29)
Writing your bio on Kloodle
Ad

Similar to The Joy of SciPy, Part I (20)

PDF
Scipy, numpy and friends
PDF
London level39
PDF
Python Científico
PDF
Python as number crunching code glue
PDF
Migrating from matlab to python
PPTX
Python-data-science.pptx
PPTX
Introduction_to_Python.pptx
PPTX
Intoduction to Python Libraries in detail.pptx
PPTX
Introduction to Python Libraries in details.pptx
PDF
Practicing Python 3
PPTX
DATA SCIENCE WITH PYTHON.pptx
PDF
RDM 2020: Python, Numpy, and Pandas
PDF
Python For Scientists
PDF
SciPy 2010 Review
PDF
Introduction to ipython notebook
PPTX
What is Python? An overview of Python for science.
PDF
Travis Oliphant "Python for Speed, Scale, and Science"
PDF
PyLadies Seattle - Lessons in Interactive Visualizations
PPTX
Python for ML
PDF
PPT4: Frameworks & Libraries of Machine Learning & Deep Learning
Scipy, numpy and friends
London level39
Python Científico
Python as number crunching code glue
Migrating from matlab to python
Python-data-science.pptx
Introduction_to_Python.pptx
Intoduction to Python Libraries in detail.pptx
Introduction to Python Libraries in details.pptx
Practicing Python 3
DATA SCIENCE WITH PYTHON.pptx
RDM 2020: Python, Numpy, and Pandas
Python For Scientists
SciPy 2010 Review
Introduction to ipython notebook
What is Python? An overview of Python for science.
Travis Oliphant "Python for Speed, Scale, and Science"
PyLadies Seattle - Lessons in Interactive Visualizations
Python for ML
PPT4: Frameworks & Libraries of Machine Learning & Deep Learning

The Joy of SciPy, Part I

  • 1. The Joy of SciPy Part I, Dinu Gherman Part II, Dave Kammeyer (not included here) Python Users Berlin Meet-up, 2013-02-14
  • 2. About… Science… Visualisation Analytics Numbers Data Math Big Data Algorithms Machine Learning … and Python
  • 3. Science, a Reminder Domains Math Education Visualisation Data Models Publication Theory Experiments
  • 4. From Scientific Python “Components”… Nat. Language Toolkit Matplotlib Mol. Modelling Toolkit SymPy Chaco PIL BioPython.org NumPy Veusz OpenCV PsychoPy.org Blaze … Scikit-image AstroPython.org Scikit-learn Stackless Pandas … PyPy PyTables Cython Disco Sphinx Numba ReST (sample) Theano ………
  • 5. … to Integrated Scientific Environments Legacy: Py-Distributions: Py-Environments: Mathematica ScientificPython IPython.org Matlab Enthought, EPD SciPy.org Maple Anaconda Sagemath.org Magma Python(x, y) Wakari.io Mathics.org Orange
  • 6. IPython Shell • Extended Inter- active Python shell • Extensions • Help • Tab completion • History • Multi-line editing • Debugger • Shell access • Bookmarks • Magic functions • DEMO…
  • 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. IPython Notebook Demo • Tour of the IPython notebook (built-in) • Installing a custom extension • Combined later with Matplotlib demo
  • 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. Matplotlib • Scientific plots • 2D, 3D, interactive • Smart axes, grids • Beautiful math (TeX) • Widgets, annotations, … • http://matplotlib.org/gallery.html
  • 11. Matplotlib Demo • Simple plots • Bézier path editor • Magic cube
  • 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
  • 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
  • 16. Exercise Run the algorithm below using CPython, Cython, PyPy and Numba and compare their performance. This is implementing a spigot algorithm by A. Sale, D. Saada, S. Rabinowitz, as mentioned on http://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]