不过,对于python初学者非常有帮助,有详尽的例子,以及循序渐进的解释。
Introduction to Python for Computational Science and Engineering
(A beginner's guide)
作者:
Hans Fangohr
Faculty of Engineering and the Environment
University of Southampton
Contents
1 Introduction
1.1 Computational Modelling
1.1.1 Introduction
1.1.2 Computational Modelling
1.1.3 Programming to support computational modelling
1.2 Why Python for scientific computing?
1.2.1 Optimisation strategies
1.2.2 Get it right first, then make it fast
1.2.3 Prototyping in Python
1.3 Literature
1.3.1 Recorded video lectures on Python for beginners
1.3.2 Python tutor mailing list
1.4 Python version
1.5 This document
1.6 Your feedback
2 A powerful calculator
2.1 Python prompt and Read-Eval-Print Loop (REPL)
2.2 Calculator
2.3 Integer division
2.3.1 How to avoid integer division
2.3.2 Why should I care about this division problem?
2.4 Mathematical functions
2.5 Variables
2.5.1 Terminology
2.6 Impossible equations
2.6.1 The += notation
3 Data Types and Data Structures
3.1 What type is it?
3.2 Numbers
3.2.1 Integers
3.2.2 Long integers
3.2.3 Floating Point numbers
3.2.4 Complex numbers
3.2.5 Functions applicable to all types of numbers
3.3 Sequences
3.3.1 Sequence type 1: String
3.3.2 Sequence type 2: List
3.3.3 Sequence type 3: Tuples
3.3.4 Indexing sequences
3.3.5 Slicing sequences
3.3.6 Dictionaries
3.4 Passing arguments to functions
3.4.1 Call by value
3.4.2 Call by reference
3.4.3 Argument passing in Python
3.4.4 Performance considerations
3.4.5 Inadvertent modification of data
3.4.6 Copying objects
3.5 Equality and Identity/Sameness
3.5.1 Equality
3.5.2 Identity / Sameness
3.5.3 Example: Equality and identity
4 Introspection
4.1 dir()
4.1.1 Magic names
4.2 type
4.3 isinstance
4.4 help
4.5 Docstrings
5 Input and Output
5.1 Printing to standard output (normally the screen)
5.1.1 Simple print (not compatible with Python 3.x)
5.1.2 Formatted printing
5.1.3 "str" and "_str_"
5.1.4 "repr" and "_repr_ "
5.1.5 Changes from Python 2 to Python 3: print
5.1.6 Changes from Python 2 to Python 3: formatting of strings
5.2 Reading and writing files
5.2.1 File reading examples
6 Control Flow
6.1 Basics
6.1.1 Conditionals
6.2 If-then-else
6.3 For loop
6.4 While loop
6.5 Relational operators (comparisons) in if and while statements
6.6 Exceptions
6.6.1 Raising Exceptions
6.6.2 Creating our own exceptions
6.6.3 LBYL vs EAFP
7 Functions and modules
7.1 Introduction
7.2 Using functions
7.3 Defining functions
7.4 Default values and optional parameters
7.5 Modules
7.5.1 Importing modules
7.5.2 Creating modules
7.5.3 Use of name
7.5.4 Example 1
7.5.5 Example 2
8 Functional tools
8.1 Anonymous functions
8.2 Map
8.3 Filter
8.4 List comprehension
8.5 Reduce
8.6 Why not just use for-loops?
8.7 Speed
9 Common tasks
9.1 Many ways to compute a series
9.2 Sorting
10 From Matlab to Python
10.1 Important commands
10.1.1 The for-loop
10.1.2 The if-then statement
10.1.3 Indexing
10.1.4 Matrices
11 Python shells
11.1 IDLE
11.2 Python (command line)
11.3 Interactive Python (IPython)
11.3.1 IPython console
11.3.2 IPython Notebook
11.4 Spyder
11.5 Editors
12 Symbolic computation
12.1 SymPy
12.1.1 Symbols
12.1.2 isympy
12.1.3 Numeric types
12.1.4 Differentiation and Integration
12.1.5 Ordinary differential equations
12.1.6 Series expansions and plotting
12.1.7 Linear equations and matrix inversion
12.1.8 Non linear equations
12.1.9 Output: LATEX interface and pretty-printing
12.1.10 Automatic generation of C code
12.2 Related tools
13 Numerical Computation
13.1 Numbers and numbers
13.1.1 Limitations of number types
13.1.2 Using floating point numbers (carelessly)
13.1.3 Using floating point numbers carefully 1
13.1.4 Using floating point numbers carefully 2
13.1.5 Symbolic calculation
13.1.6 Summary
13.1.7 Exercise: infinite or finite loop
14 Numerical Python (numpy): arrays
14.1 Numpy introduction
14.1.1 History
14.1.2 Arrays
14.1.3 Convert from array to list or tuple
14.1.4 Standard Linear Algebra operations
14.1.5 More numpy examples
14.1.6 Numpy for Matlab users
15 Visualising Data
15.1 Matplotlib (Pylab) { plotting y=f(x), (and a bit more)
15.1.1 Matplotlib and Pylab
15.1.2 First example
15.1.3 How to import matplotlib, pylab, pyplot, numpy and all that
15.1.4 IPython's inline mode
15.1.5 Saving the figure to a file
15.1.6 Interactive mode
15.1.7 Fine tuning your plot
15.1.8 Plotting more than one curve
15.1.9 Histograms
15.1.10 Visualising matrix data
15.1.11 Plots of z = f(x; y) and other features of Matplotlib
15.2 Visual Python
15.2.1 Basics, rotating and zooming
15.2.2 Setting the frame rate for animations
15.2.3 Tracking trajectories
15.2.4 Connecting objects (Cylinders, springs, . . . )
15.2.5 3d vision
15.3 Visualising higher dimensional data
15.3.1 Mayavi, Paraview, Visit
15.3.2 Writing vtk les from Python (pyvtk)
16 Numerical Methods using Python (scipy)
16.1 Overview
16.2 SciPy
16.3 Numerical integration
16.3.1 Exercise: integrate a function
16.3.2 Exercise: plot before you integrate
16.4 Solving ordinary differential equations
16.4.1 Exercise: using odeint
16.5 Root finding
16.5.1 Root finding using the bisection method
16.5.2 Exercise: root finding using the bisect method
16.5.3 Root finding using the fsolve function
16.6 Interpolation
16.7 Curve fitting
16.8 Fourier transforms
16.9 Optimisation
16.10 Other numerical methods
16.11 scipy.io: Scipy-input output
17 Where to go from here?
17.1 Advanced programming
17.2 Compiled programming language
17.3 Testing
17.4 Simulation models
17.5 Software engineering for research codes
17.6 Data and visualisation
17.7 Version control
17.8 Parallel execution