Upgrade to Pro — share decks privately, control downloads, hide ads and more …

UvA API software carpentry IPython Notebooks 2015

Gijs Molenaar
September 18, 2015

UvA API software carpentry IPython Notebooks 2015

Gijs Molenaar

September 18, 2015
Tweet

More Decks by Gijs Molenaar

Other Decks in Science

Transcript

  1. Agenda • Short presentation ◦ ‘Advanced’ Python topics ◦ Ipython

    notebooks • Interactive session • if time interactive git merge (didn’t finish last week) • Half way short coffee break
  2. Python 3 • Please write Python 3 compatible code •

    http://python-future.org/overview.html • 3.5 has been released ◦ @ operator (matrix multiplication) ◦ Parallel build of C extensions ◦ Much more!
  3. PyCharm IDE Static code analysis Interactive debugger Integrated test suite

    runner Free ‘community’ edition Free for students (didn’t try)
  4. Object Oriented programming Not the holey grail Can be useful

    if used properly Is dramatic when used wrong You can solve most problem with functional programming Python programming using functions and python primitives (list, dict, try out collections.namedtuple )
  5. profiling $ pip install runsnakerun $ python -m cProfile -o

    profile.dat script.py $ runsnake profile.dat
  6. pip because --system-site-packages already packages installed $ pip search astropy

    astropy - Community-developed python astronomy tools INSTALLED: 0.3 LATEST: 1.0.4 to install new packages in your virtualenv $ pip install notebook you can also upgrade / override system wide installed packages $ pip install --upgrade astropy
  7. ipython notebook $ which ipython /scratch/gijs/venv/bin/ipython task: pick an arbitrary

    port number > 1024 and < 65535 (maybe a birthday paradox!) $ ipython notebook --no-browser --port=<number> (default is 8888)
  8. $ ssh -L 8000:localhost:6666 taurus $ cd /scratch/gijs/ $ source

    venv/bin/activate (venv)$ cd ipython-workshop (venv)$ pip install -r requirements.txt (venv)$ ipython notebook --no-browser --port=6666
  9. IPython notebooks. We will talk about security Processes The state

    and how to change it cells returned object from last statement is shown below cell Markdown astropy Mixing Python and Bash