python: part 4 - national institute for computational … crash course packages and modules a module...
TRANSCRIPT
Python Crash Course
Packages and Modules
A module is a file containing Python definitions, functions, classes and statements.
A package is simply a collection of modules organized in a directory
Python Crash Course
Packages and ModulesGeometry
Area
Volume
Rectangle
Circle
Cube
Sphere
http://www.slideshare.net/p3infotech_solutions/python-programming-essentials-m18-modules-and-packages
Python Crash Course http://python-packaging-user-guide.readthedocs.org/en/latest/installing/
$pip3installmatplotlib
$pip3install-Upip
$pip3install-Unumpy
OnWindowspython-mpipinstall-Upipsetuptools
How to install packages?
Python Crash Course
Numpy Tutorial
https://docs.scipy.org/doc/numpy-dev/user/quickstart.html
Python Crash Course
Plotting library for Python
http://matplotlib.org/index.html
Python Crash Course
Pyplot Tutorial
http://matplotlib.org/users/pyplot_tutorial.html
Python Crash Course
Pyplot
http://matplotlib.org/api/pyplot_summary.html
Python Crash Course
Pyplot Tutorial
http://matplotlib.org/users/pyplot_tutorial.html
Python Crash Course
Plot from a file
import pylabdata= pylab.loadtxt('input.txt')pylab.plot (data[:,0], data[:,1])pylab.show()
$ cat > input.txt1 23 45 67 8
Python Crash Course
SciPy - Core packages
http://scipy.org/
• Python, a general purpose programming language. It is interpreted and dynamically typed and is very suited for interactive work and quick prototyping, while being powerful enough to write large applications in.
• NumPy, the fundamental package for numerical computation. It defines the numerical array and matrix types and basic operations on them.
• The SciPy library, a collection of numerical algorithms and domain-specific toolboxes, including signal processing, optimization, statistics and much more.
• Matplotlib, a mature and popular plotting package, that provides publication-quality 2D plotting as well as rudimentary 3D plotting
• pandas, providing high-performance, easy to use data structures.• SymPy, for symbolic mathematics and computer algebra.• IPython, a rich interactive interface, letting you quickly process data and test
ideas. The IPython notebook works in your web browser, allowing you to document your computation in an easily reproducible form.
• nose, a framework for testing Python code.
Python Crash Course
SciPy - Other packages
http://scipy.org/
• Chaco is another Python plotting toolkit designed from the ground up to be great for embedded, interactive plotting. It is built on Traits, both are part of the Enthought Tool Suite.
• Mayavi is a powerful and user-friendly framework for 3D visualization, built on top of the award winning Visualization Toolkit, VTK.
• Cython extends Python syntax so that you can conveniently build C extensions, either to speed up critical code, or to integrate with C/C++ libraries.
• Scikits are extra packages for more specific functionality. scikit-image and scikit-learn are two of the most prominent.
• h5py and PyTables can both access data stored in the HDF5 format.