Начать новую тему Ответить на тему
Статистика раздачи
Размер: 6.31 МБ | | Скачали: 1
Сидеров: 0  [0 байт/сек]    Личеров: 0  [0 байт/сек]
Пред. тема | След. тема 

Автор
Сообщение

Ответить с цитатой 

Python Scripting for Computational Science

Год издания: 2008
Автор: Hans Petter Langtangen
Жанр или тематика: Computer Science

Издательство: Springer
ISBN: 978-3-540-73915-9
Серия: Texts in Computational Science and Engineering
Язык: Английский

Формат: PDF
Качество: Отсканированные страницы + слой распознанного текста
Интерактивное оглавление: Нет
Количество страниц: 769

Описание: With a primary focus on examples and applications of relevance to computational scientists, this brilliantly useful book shows computational scientists how to develop tailored, flexible, and human-efficient working environments built from small scripts written in the easy-to-learn, high-level Python language. All the tools and examples in this book are open source codes. This third edition features lots of new material. It is also released after a comprehensive reorganization of the text. The author has inserted improved examples and tools and updated information, as well as correcting any errors that crept in to the first imprint.
Table of Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Scripting versus Traditional Programming . . . . . . . . . . . . . . . . .
1.1.1 Why Scripting is Useful in Computational Science . . .
1.1.2 Classification of Programming Languages . . . . . . . . . .
1.1.3 Productive Pairs of Programming Languages . . . . . . .
1.1.4 Gluing Existing Applications . . . . . . . . . . . . . . . . . . . . .
1.1.5 Scripting Yields Shorter Code . . . . . . . . . . . . . . . . . . . .
1.1.6 Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.7 Type-Specification (Declaration) of Variables . . . . . . .
1.1.8 Flexible Function Interfaces . . . . . . . . . . . . . . . . . . . . . .
1.1.9 Interactive Computing . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.10 Creating Code at Run Time . . . . . . . . . . . . . . . . . . . . . .
1.1.11 Nested Heterogeneous Data Structures . . . . . . . . . . . . .
1.1.12 GUI Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.13 Mixed Language Programming . . . . . . . . . . . . . . . . . . .
1.1.14 When to Choose a Dynamically Typed Language . . .
1.1.15 Why Python? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.16 Script or Program? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Preparations for Working with This Book . . . . . . . . . . . . . . . . .

Getting Started with Python Scripting . . . . . . . . . . . . 27

A Scientific Hello World Script . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1.1 Executing Python Scripts . . . . . . . . . . . . . . . . . . . . . . . .
2.1.2 Dissection of the Scientific Hello World Script . . . . . .
Working with Files and Data . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.1 Problem Specification . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.2 The Complete Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.3 Dissection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.4 Working with Files in Memory . . . . . . . . . . . . . . . . . . . .
2.2.5 Array Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.6 Interactive Computing and Debugging . . . . . . . . . . . . .
2.2.7 Efficiency Measurements . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Gluing Stand-Alone Applications . . . . . . . . . . . . . . . . . . . . . . . .
2.3.1 The Simulation Code . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.2 Using Gnuplot to Visualize Curves . . . . . . . . . . . . . . . .
2.3.3 Functionality of the Script . . . . . . . . . . . . . . . . . . . . . . .
2.3.4 The Complete Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.5 Dissection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Conducting Numerical Experiments . . . . . . . . . . . . . . . . . . . . . .
2.4.1 Wrapping a Loop Around Another Script . . . . . . . . . .
2.4.2 Generating an HTML Report . . . . . . . . . . . . . . . . . . . . .
2.4.3 Making Animations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4.4 Varying Any Parameter . . . . . . . . . . . . . . . . . . . . . . . . . .
File Format Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5.1 A Simple Read/Write Script . . . . . . . . . . . . . . . . . . . . . .
2.5.2 Storing Data in Dictionaries and Lists . . . . . . . . . . . . .
2.5.3 Making a Module with Functions . . . . . . . . . . . . . . . . .
2.5.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Basic Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Introductory Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.1 Recommended Python Documentation . . . . . . . . . . . . .
3.1.2 Control Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.3 Running Applications . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1.4 File Reading and Writing . . . . . . . . . . . . . . . . . . . . . . . .
3.1.5 Output Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Variables of Different Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.1 Boolean Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.2 The None Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.3 Numbers and Numerical Expressions . . . . . . . . . . . . . .
3.2.4 Lists and Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.5 Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.6 Splitting and Joining Text . . . . . . . . . . . . . . . . . . . . . . .
3.2.7 String Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.8 Text Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.9 The Basics of a Python Class . . . . . . . . . . . . . . . . . . . . .
3.2.10 Copy and Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.11 Determining a Variable’s Type . . . . . . . . . . . . . . . . . . . .
3.2.12 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.1 Keyword Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.2 Doc Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.3 Variable Number of Arguments . . . . . . . . . . . . . . . . . . .
3.3.4 Call by Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.5 Treatment of Input and Output Arguments . . . . . . . .
3.3.6 Function Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Working with Files and Directories . . . . . . . . . . . . . . . . . . . . . . .
3.4.1 Listing Files in a Directory . . . . . . . . . . . . . . . . . . . . . . .
3.4.2 Testing File Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4.3 Removing Files and Directories . . . . . . . . . . . . . . . . . . .
3.4.4 Copying and Renaming Files . . . . . . . . . . . . . . . . . . . . .
3.4.5 Splitting Pathnames . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4.6 Creating and Moving to Directories . . . . . . . . . . . . . . .
3.4.7 Traversing Directory Trees . . . . . . . . . . . . . . . . . . . . . . .
3.4.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Numerical Computing in Python . . . . . . . . . . . . . . . . . . . 131

A Quick NumPy Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.1 Creating Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.2 Array Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.3 Loops over Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.4 Array Computations . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.5 More Array Functionality . . . . . . . . . . . . . . . . . . . . . . . .
4.1.6 Type Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.7 Matrix Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Vectorized Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2.1 From Scalar to Array in Function Arguments . . . . . . .
4.2.2 Slicing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
More Advanced Array Computing . . . . . . . . . . . . . . . . . . . . . . . .
4.3.1 Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3.2 Linear Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3.3 Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3.4 Example: Curve Fitting . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3.5 Arrays on Structured Grids . . . . . . . . . . . . . . . . . . . . . .
4.3.6 File I/O with NumPy Arrays . . . . . . . . . . . . . . . . . . . . .
4.3.7 Functionality in the Numpyutils Module . . . . . . . . . . .
4.3.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Other Tools for Numerical Computations . . . . . . . . . . . . . . . . .
4.4.1 The ScientificPython Package . . . . . . . . . . . . . . . . . . . .
4.4.2 The SciPy Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.3 The Python–Matlab Interface . . . . . . . . . . . . . . . . . . . .
4.4.4 Symbolic Computing in Python . . . . . . . . . . . . . . . . . . .
4.4.5 Some Useful Python Modules . . . . . . . . . . . . . . . . . . . . .

Combining Python with Fortran, C, and C++ . . . . 189

About Mixed Language Programming . . . . . . . . . . . . . . . . . . . .
5.1.1 Applications of Mixed Language Programming . . . . . .
5.1.2 Calling C from Python . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.3 Automatic Generation of Wrapper Code . . . . . . . . . . .
Scientific Hello World Examples . . . . . . . . . . . . . . . . . . . . . . . . .
5.2.1 Combining Python and Fortran . . . . . . . . . . . . . . . . . . .
5.2.2 Combining Python and C . . . . . . . . . . . . . . . . . . . . . . . .
5.2.3 Combining Python and C++ Functions . . . . . . . . . . . .
5.2.4 Combining Python and C++ Classes . . . . . . . . . . . . . .
5.2.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A Simple Computational Steering Example . . . . . . . . . . . . . . . .
5.3.1 Modified Time Loop for Repeated Simulations . . . . . .
5.3.2 Creating a Python Interface . . . . . . . . . . . . . . . . . . . . . .
5.3.3 The Steering Python Script . . . . . . . . . . . . . . . . . . . . . .
5.3.4 Equipping the Steering Script with a GUI . . . . . . . . . .
Scripting Interfaces to Large Libraries . . . . . . . . . . . . . . . . . . . .

Introduction to GUI Programming . . . . . . . . . . . . . . . . . 227

Scientific Hello World GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1.1 Introductory Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1.2 The First Python/Tkinter Encounter . . . . . . . . . . . . . .
6.1.3 Binding Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1.4 Changing the Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1.5 The Final Scientific Hello World GUI . . . . . . . . . . . . . .
6.1.6 An Alternative to Tkinter Variables . . . . . . . . . . . . . . .
6.1.7 About the Pack Command . . . . . . . . . . . . . . . . . . . . . . .
6.1.8 An Introduction to the Grid Geometry Manager . . . .
6.1.9 Implementing a GUI as a Class . . . . . . . . . . . . . . . . . . .
6.1.10 A Simple Graphical Function Evaluator . . . . . . . . . . . .
6.1.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Adding GUIs to Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2.1 A Simulation and Visualization Script with a GUI . .
6.2.2 Improving the Layout . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A List of Common Widget Operations . . . . . . . . . . . . . . . . . . . .
6.3.1 Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.2 Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.3 Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.4 Text Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.5 Balloon Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.6 Option Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.7 Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.8 Check Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.9 Making a Simple Megawidget . . . . . . . . . . . . . . . . . . . . .
6.3.10 Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.11 List Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.12 Listbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.13 Radio Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.14 Combo Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.15 Message Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.16 User-Defined Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.17 Color-Picker Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.18 File Selection Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.19 Toplevel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.20 Some Other Types of Widgets . . . . . . . . . . . . . . . . . . . .
6.3.21 Adapting Widgets to the User’s Resize Actions . . . . .
6.3.22 Customizing Fonts and Colors . . . . . . . . . . . . . . . . . . . .
6.3.23 Widget Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.24 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Web Interfaces and CGI Programming . . . . . . . . . . . . . 295

Introductory CGI Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1.1 Web Forms and CGI Scripts . . . . . . . . . . . . . . . . . . . . . .
7.1.2 Generating Forms in CGI Scripts . . . . . . . . . . . . . . . . .
7.1.3 Debugging CGI Scripts . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1.4 A General Shell Script Wrapper for CGI Scripts . . . .
7.1.5 Security Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Adding Web Interfaces to Scripts . . . . . . . . . . . . . . . . . . . . . . . .
7.2.1 A Class for Form Parameters . . . . . . . . . . . . . . . . . . . . .
7.2.2 Calling Other Programs . . . . . . . . . . . . . . . . . . . . . . . . .
7.2.3 Running Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.2.4 Getting a CGI Script to Work . . . . . . . . . . . . . . . . . . . .
7.2.5 Using Web Applications from Scripts . . . . . . . . . . . . . .
7.2.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Advanced Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

Miscellaneous Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.1 Parsing Command-Line Arguments . . . . . . . . . . . . . . . .
8.1.2 Platform-Dependent Operations . . . . . . . . . . . . . . . . . .
8.1.3 Run-Time Generation of Code . . . . . . . . . . . . . . . . . . . .
8.1.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Regular Expressions and Text Processing . . . . . . . . . . . . . . . . .
8.2.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2.2 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2.3 Regular Expressions for Real Numbers . . . . . . . . . . . . .
8.2.4 Using Groups to Extract Parts of a Text . . . . . . . . . . .
8.2.5 Extracting Interval Limits . . . . . . . . . . . . . . . . . . . . . . . .
8.2.6 Extracting Multiple Matches . . . . . . . . . . . . . . . . . . . . .
8.2.7 Splitting Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2.8 Pattern-Matching Modifiers . . . . . . . . . . . . . . . . . . . . . .
8.2.9 Substitution and Backreferences . . . . . . . . . . . . . . . . . .
8.2.10 Example: Swapping Arguments in Function Calls . . .
8.2.11 A General Substitution Script . . . . . . . . . . . . . . . . . . . .
8.2.12 Debugging Regular Expressions . . . . . . . . . . . . . . . . . . .
8.2.13 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Tools for Handling Data in Files . . . . . . . . . . . . . . . . . . . . . . . . .
8.3.1 Writing and Reading Python Data Structures . . . . . .
8.3.2 Pickling Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3.3 Shelving Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3.4 Writing and Reading Zip and Tar Archive Files . . . . .
8.3.5 Downloading Internet Files . . . . . . . . . . . . . . . . . . . . . . .
8.3.6 Binary Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A Database for NumPy Arrays . . . . . . . . . . . . . . . . . . . . . . . . . .
8.4.1 The Structure of the Database . . . . . . . . . . . . . . . . . . . .
8.4.2 Pickling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.4.3 Formatted ASCII Storage . . . . . . . . . . . . . . . . . . . . . . . .
8.4.4 Shelving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.4.5 Comparing the Various Techniques . . . . . . . . . . . . . . . .
8.5 Scripts Involving Local and Remote Hosts . . . . . . . . . . . . . . . . .
8.5.1 Secure Shell Commands . . . . . . . . . . . . . . . . . . . . . . . . .
8.5.2 Distributed Simulation and Visualization . . . . . . . . . .
8.5.3 Client/Server Programming . . . . . . . . . . . . . . . . . . . . . .
8.5.4 Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.1 Class Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.2 Checking the Class Type . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.3 Private Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.4 Static Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.5 Special Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.6 Special Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.7 Multiple Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.8 Using a Class as a C-like Structure . . . . . . . . . . . . . . . .
8.6.9 Attribute Access via String Names . . . . . . . . . . . . . . . .
8.6.10 New-Style Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6.11 Implementing Get/Set Functions via Properties . . . . .
8.6.12 Subclassing Built-in Types . . . . . . . . . . . . . . . . . . . . . . .
8.6.13 Building Class Interfaces at Run Time . . . . . . . . . . . . .
8.6.14 Building Flexible Class Interfaces . . . . . . . . . . . . . . . . .
8.6.15 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.7 Scope of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.7.1 Global, Local, and Class Variables . . . . . . . . . . . . . . . .
8.7.2 Nested Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.7.3 Dictionaries of Variables in Namespaces . . . . . . . . . . . .
8.8 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.8.1 Handling Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.8.2 Raising Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.9 Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.9.1 Constructing an Iterator . . . . . . . . . . . . . . . . . . . . . . . . .
8.9.2 A Pointwise Grid Iterator . . . . . . . . . . . . . . . . . . . . . . . .
8.9.3 A Vectorized Grid Iterator . . . . . . . . . . . . . . . . . . . . . . .
8.9.4 Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.9.5 Some Aspects of Generic Programming . . . . . . . . . . . .
8.9.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.10 Investigating Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.10.1 CPU-Time Measurements . . . . . . . . . . . . . . . . . . . . . . . .
8.10.2 Profiling Python Scripts . . . . . . . . . . . . . . . . . . . . . . . . .
8.10.3 Optimization of Python Code . . . . . . . . . . . . . . . . . . . .
8.10.4 Case Study on Numerical Efficiency . . . . . . . . . . . . . . .
Fortran Programming with NumPy Arrays . . . . . . . 451
Problem Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Filling an Array in Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2.1 The Fortran Subroutine . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2.2 Building and Inspecting the Extension Module . . . . . .
Array Storage Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.3.1 Generating an Erroneous Interface . . . . . . . . . . . . . . . .
9.3.2 Array Storage in C and Fortran . . . . . . . . . . . . . . . . . . .
9.3.3 Input and Output Arrays as Function Arguments . . .
9.3.4 F2PY Interface Files . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.3.5 Hiding Work Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Increasing Callback Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.4.1 Callbacks to Vectorized Python Functions . . . . . . . . . .
9.4.2 Avoiding Callbacks to Python . . . . . . . . . . . . . . . . . . . .
9.4.3 Compiled Inline Callback Functions . . . . . . . . . . . . . . .
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10 C and C++ Programming with NumPy Arrays . . 483
10.1 Automatic Interfacing of C/C++ Code . . . . . . . . . . . . . . . . . . .
10.1.1 Using F2PY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.1.2 Using Instant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.1.3 Using Weave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2 C Programming with NumPy Arrays . . . . . . . . . . . . . . . . . . . . .
10.2.1 The Basics of the NumPy C API . . . . . . . . . . . . . . . . . .
10.2.2 The Handwritten Extension Code . . . . . . . . . . . . . . . . .
10.2.3 Sending Arguments from Python to C . . . . . . . . . . . . .
10.2.4 Consistency Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2.5 Computing Array Values . . . . . . . . . . . . . . . . . . . . . . . . .
10.2.6 Returning an Output Array . . . . . . . . . . . . . . . . . . . . . .
10.2.7 Convenient Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2.8 Module Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2.9 Extension Module Template . . . . . . . . . . . . . . . . . . . . . .
10.2.10 Compiling, Linking, and Debugging the Module . . . . .
10.2.11 Writing a Wrapper for a C Function . . . . . . . . . . . . . . .
10.3 C++ Programming with NumPy Arrays . . . . . . . . . . . . . . . . . .
10.3.1 Wrapping a NumPy Array in a C++ Object . . . . . . .
10.3.2 Using SCXX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.3.3 NumPy–C++ Class Conversion . . . . . . . . . . . . . . . . . . .
10.4 Comparison of the Implementations . . . . . . . . . . . . . . . . . . . . . .
10.4.1 Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4.2 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.4.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11 More Advanced GUI Programming . . . . . . . . . . . . . . . . . 529
11.1 Adding Plot Areas in GUIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.1.1 The BLT Graph Widget . . . . . . . . . . . . . . . . . . . . . . . . .
11.1.2 Animation of Functions in BLT Graph Widgets . . . . .
11.1.3 Other Tools for Making GUIs with Plots . . . . . . . . . . .
11.1.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.2 Event Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.2.1 Binding Events to Functions with Arguments . . . . . . .
11.2.2 A Text Widget with Tailored Keyboard Bindings . . .
11.2.3 A Fancy List Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.3 Animated Graphics with Canvas Widgets . . . . . . . . . . . . . . . . .
11.3.1 The First Canvas Encounter . . . . . . . . . . . . . . . . . . . . . .
11.3.2 Coordinate Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.3.3 The Mathematical Model Class . . . . . . . . . . . . . . . . . . .
11.3.4 The Planet Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.3.5 Drawing and Moving Planets . . . . . . . . . . . . . . . . . . . . .
11.3.6 Dragging Planets to New Positions . . . . . . . . . . . . . . . .
11.3.7 Using Pmw’s Scrolled Canvas Widget . . . . . . . . . . . . . .
11.4 Simulation and Visualization Scripts . . . . . . . . . . . . . . . . . . . . .
11.4.1 Restructuring the Script . . . . . . . . . . . . . . . . . . . . . . . . .
11.4.2 Representing a Parameter by a Class . . . . . . . . . . . . . .
11.4.3 Improved Command-Line Script . . . . . . . . . . . . . . . . . .
11.4.4 Improved GUI Script . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.4.5 Improved CGI Script . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11.4.6 Parameters with Physical Dimensions . . . . . . . . . . . . .
11.4.7 Adding a Curve Plot Area . . . . . . . . . . . . . . . . . . . . . . .
11.4.8 Automatic Generation of Scripts . . . . . . . . . . . . . . . . . .
11.4.9 Applications of the Tools . . . . . . . . . . . . . . . . . . . . . . . .
11.4.10 Allowing Physical Units in Input Files . . . . . . . . . . . . .
11.4.11 Converting Input Files to GUIs . . . . . . . . . . . . . . . . . . .
12 Tools and Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
12.1 Running Series of Computer Experiments . . . . . . . . . . . . . . . . .
12.1.1 Multiple Values of Input Parameters . . . . . . . . . . . . . .
12.1.2 Implementation Details . . . . . . . . . . . . . . . . . . . . . . . . . .
12.1.3 Further Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.2 Tools for Representing Functions . . . . . . . . . . . . . . . . . . . . . . . . .
12.2.1 Functions Defined by String Formulas . . . . . . . . . . . . .
12.2.2 A Unified Interface to Functions . . . . . . . . . . . . . . . . . .
12.2.3 Interactive Drawing of Functions . . . . . . . . . . . . . . . . . .
12.2.4 A Notebook for Selecting Functions . . . . . . . . . . . . . . .
12.3 Solving Partial Differential Equations . . . . . . . . . . . . . . . . . . . . .
12.3.1 Numerical Methods for 1D Wave Equations . . . . . . . .
12.3.2 Implementations of 1D Wave Equations . . . . . . . . . . . .
12.3.3 Classes for Solving 1D Wave Equations . . . . . . . . . . . .
12.3.4 A Problem Solving Environment . . . . . . . . . . . . . . . . . .
12.3.5 Numerical Methods for 2D Wave Equations . . . . . . . .
12.3.6 Implementations of 2D Wave Equations . . . . . . . . . . . . 666
12.3.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
A Setting up the Required Software Environment . . . 677
A.1 Installation on Unix Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.1 A Suggested Directory Structure . . . . . . . . . . . . . . . . . .
A.1.2 Setting Some Environment Variables . . . . . . . . . . . . . .
A.1.3 Installing Tcl/Tk and Additional Modules . . . . . . . . .
A.1.4 Installing Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.5 Installing Python Modules . . . . . . . . . . . . . . . . . . . . . . .
A.1.6 Installing Gnuplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.7 Installing SWIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1.8 Summary of Environment Variables . . . . . . . . . . . . . . .
A.1.9 Testing the Installation of Scripting Utilities . . . . . . . .
A.2 Installation on Windows Systems . . . . . . . . . . . . . . . . . . . . . . . .
B Elements of Software Engineering . . . . . . . . . . . . . . . . . . . 689
Building and Using Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.1.1 Single-File Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.1.2 Multi-File Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.1.3 Debugging and Troubleshooting . . . . . . . . . . . . . . . . . . .
Tools for Documenting Python Software . . . . . . . . . . . . . . . . . .
B.2.1 Doc Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.2.2 Tools for Automatic Documentation . . . . . . . . . . . . . . .
Coding Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.3.1 Style Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.3.2 Pythonic Programming . . . . . . . . . . . . . . . . . . . . . . . . . .
Verification of Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.4.1 Automating Regression Tests . . . . . . . . . . . . . . . . . . . . .
B.4.2 Implementing a Tool for Regression Tests . . . . . . . . . .
B.4.3 Writing a Test Script . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.4.4 Verifying Output from Numerical Computations . . . .
B.4.5 Automatic Doc String Testing . . . . . . . . . . . . . . . . . . . .
B.4.6 Unit Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Version Control Management . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.5.1 Mercurial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.5.2 Subversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
Exercise 2.1
Exercise 2.2
Exercise 2.3
Exercise 2.4
Exercise 2.5
Exercise 2.6
Exercise 2.7
Exercise 2.8
Exercise 2.9
Exercise 2.10
Exercise 2.11
Exercise 2.12
Exercise 2.13
Exercise 2.14
Exercise 2.15
Exercise 2.16
Exercise 2.17
Exercise 3.1
Exercise 3.2
Exercise 3.3
Exercise 3.4
Exercise 3.5
Exercise 3.6
Exercise 3.7
Exercise 3.8
Exercise 3.9
Exercise 3.10
Exercise 3.11
Exercise 3.12
Exercise 3.13
Exercise 3.14
Exercise 3.15
Exercise 3.16
Exercise 3.17
Exercise 3.18
Exercise 3.19
Exercise 4.1
Exercise 4.2
Exercise 4.3
Exercise 4.4
Become familiar with the electronic documentation . . . . .
Extend Exercise 2.1 with a loop . . . . . . . . . . . . . . . . . . . . .
Find five errors in a script . . . . . . . . . . . . . . . . . . . . . . . . . .
Basic use of control structures . . . . . . . . . . . . . . . . . . . . . . .
Use standard input/output instead of files . . . . . . . . . . . . .
Read streams of (x, y) pairs from the command line . . . .
Test for specific exceptions . . . . . . . . . . . . . . . . . . . . . . . . . .
Sum columns in a file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Estimate the chance of an event in a dice game . . . . . . . .
Determine if you win or loose a hazard game . . . . . . . . . .
Generate an HTML report from the simviz1.py script . .
Generate a L A TEX report from the simviz1.py script . . . .
Compute time step values in the simviz1.py script . . . . .
Use Matlab for curve plotting in the simviz1.py script . .
Combine curves from two simulations in one plot . . . . . . .
Combine two-column data files to a multi-column file . . .
Read/write Excel data files in Python . . . . . . . . . . . . . . . .
Write format specifications in printf-style . . . . . . . . . . . . .
Write your own function for joining strings . . . . . . . . . . . .
Write an improved function for joining strings . . . . . . . . .
Never modify a list you are iterating on . . . . . . . . . . . . . . .
Make a specialized sort function . . . . . . . . . . . . . . . . . . . . .
Check if your system has a specific program . . . . . . . . . . .
Find the paths to a collection of programs . . . . . . . . . . . .
Use Exercise 3.7 to improve the simviz1.py script . . . . . .
Use Exercise 3.7 to improve the loop4simviz2.py script .
Find the version number of a utility . . . . . . . . . . . . . . . . . .
Automate execution of a family of similar commands . . .
Remove temporary files in a directory tree . . . . . . . . . . . .
Find old and large files in a directory tree . . . . . . . . . . . . .
Remove redundant files in a directory tree . . . . . . . . . . . .
Annotate a filename with the current date . . . . . . . . . . . .
Automatic backup of recently modified files . . . . . . . . . . .
Search for a text in files with certain extensions . . . . . . . .
Search directories for plots and make HTML report . . . .
Fix Unix/Windows Line Ends . . . . . . . . . . . . . . . . . . . . . . .
Matrix-vector multiply with NumPy arrays . . . . . . . . . . . .
Work with slicing and matrix multiplication . . . . . . . . . . .
Assignment and in-place NumPy array modifications . . .
Vectorize a constant function . . . . . . . . . . . . . . . . . . . . . . . .

List of Exercises
Exercise 4.5
Exercise 4.6
Exercise 4.7
Exercise 4.8
Exercise 4.9
Exercise 4.10
Exercise 4.11
Exercise 4.12
Exercise 4.13
Exercise 4.14
Exercise 4.15
Exercise 4.16
Exercise 4.17
Exercise 4.18
Exercise 4.19
Exercise 5.1
Exercise 5.2
Exercise 5.3
Exercise 6.1
Exercise 6.2
Exercise 6.3
Exercise 6.4
Exercise 6.5
Exercise 6.6
Exercise 6.7
Exercise 6.8
Exercise 6.9
Exercise 6.10
Exercise 6.11
Exercise 6.12
Exercise 6.13
Exercise 6.14
Exercise 6.15
Exercise 6.16
Exercise 6.17
Exercise 6.18
Exercise 6.19
Exercise 7.1
Exercise 7.2
Exercise 7.3
Exercise 7.4
Exercise 7.5
Exercise 8.1
Exercise 8.2
Exercise 8.3
Vectorize a numerical integration rule . . . . . . . . . . . . . . . .
Vectorize a formula containing an if condition . . . . . . . . .
Slicing of two-dimensional arrays . . . . . . . . . . . . . . . . . . . . .
Implement Exercise 2.9 using NumPy arrays . . . . . . . . . .
Implement Exercise 2.10 using NumPy arrays . . . . . . . . .
Replace lists by NumPy arrays in convert2.py . . . . . . . . .
Use Easyviz in the simviz1.py script . . . . . . . . . . . . . . . . .
Extension of Exercise 2.8 . . . . . . . . . . . . . . . . . . . . . . . . . . .
NumPy arrays and binary files . . . . . . . . . . . . . . . . . . . . . . .
One-dimensional Monte Carlo integration . . . . . . . . . . . . .
Higher-dimensional Monte Carlo integration . . . . . . . . . . .
Load data file into NumPy array and visualize . . . . . . . . .
Analyze trends in the data from Exercise 4.16 . . . . . . . . .
Evaluate a function over a 3D grid . . . . . . . . . . . . . . . . . . .
Evaluate a function over a plane or line in a 3D grid . . . .
Implement a numerical integration rule in F77 . . . . . . . . .
Implement a numerical integration rule in C . . . . . . . . . . .
Implement a numerical integration rule in C++ . . . . . . . .
Modify the Scientific Hello World GUI . . . . . . . . . . . . . . . .
Change the layout of the GUI in Exercise 6.1 . . . . . . . . . .
Control a layout with the grid geometry manager . . . . . .
Make a demo of Newton’s method . . . . . . . . . . . . . . . . . . .
Program with Pmw.EntryField in hwGUI10.py . . . . . . . . . . .
Program with Pmw.EntryField in simvizGUI2.py . . . . . . . .
Replace Tkinter variables by set/get-like functions . . . . .
Use simviz1.py as a module in simvizGUI2.py . . . . . . . . . .
Apply Matlab for visualization in simvizGUI2.py . . . . . . .
Program with Pmw.OptionMenu in simvizGUI2.py . . . . . . . .
Study the nonlinear motion of a pendulum . . . . . . . . . . . .
Add error handling with an associated message box . . . .
Add a message bar to a balloon help . . . . . . . . . . . . . . . . .
Select a file from a list and perform an action . . . . . . . . . .
Make a GUI for finding and selecting font names . . . . . . .
Launch a GUI when command-line options are missing .
Write a GUI for Exercise 3.14 . . . . . . . . . . . . . . . . . . . . . . .
Write a GUI for selecting files to be plotted . . . . . . . . . . .
Write an easy-to-use GUI generator . . . . . . . . . . . . . . . . . .
Write a CGI debugging tool . . . . . . . . . . . . . . . . . . . . . . . . .
Make a web calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Make a web application for registering participants . . . . .
Make a web application for numerical experiments . . . . .
Become a “nobody” user on a web server . . . . . . . . . . . . .
Use the getopt / optparse module in simviz1.py . . . . . . . .
Store command-line options in a dictionary . . . . . . . . . . . .
Turn files with commands into Python variables . . . . . . .

List of Exercises
Exercise 8.4
Exercise 8.5
Exercise 8.6
Exercise 8.7
Exercise 8.8
Exercise 8.9
Exercise 8.10
Exercise 8.11
Exercise 8.12
Exercise 8.13
Exercise 8.14
Exercise 8.15
Exercise 8.16
Exercise 8.17
Exercise 8.18
Exercise 8.19
Exercise 8.20
Exercise 8.21
Exercise 8.22
Exercise 8.23
Exercise 8.24
Exercise 8.25
Exercise 8.26
Exercise 8.27
Exercise 8.28
Exercise 8.29
Exercise 8.30
Exercise 8.31
Exercise 8.32
Exercise 8.33
Exercise 8.34
Exercise 8.35
Exercise 9.1
Exercise 9.2
Exercise 9.3
Exercise 9.4
Exercise 9.5
Exercise 9.6
Exercise 9.7
Exercise 10.1
Exercise 10.2
Exercise 10.3
Exercise 10.4
Exercise 10.5
Exercise 10.6
A grep script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Experiment with a regex for real numbers . . . . . . . . . . . . .
Find errors in regular expressions . . . . . . . . . . . . . . . . . . . .
Generate data from a user-supplied formula . . . . . . . . . . .
Explain the behavior of regular expressions . . . . . . . . . . . .
Edit extensions in filenames . . . . . . . . . . . . . . . . . . . . . . . . .
Extract info from a program code . . . . . . . . . . . . . . . . . . . .
Regex for splitting a pathname . . . . . . . . . . . . . . . . . . . . . .
Rename a collection of files according to a pattern . . . . .
Reimplement the re.findall function . . . . . . . . . . . . . . . . .
Interpret a regex code and find programming errors . . . .
Automatic fine tuning of PostScript figures . . . . . . . . . . . .
Transform a list of lines to a list of paragraphs . . . . . . . . .
Copy computer codes into documents . . . . . . . . . . . . . . . . .
A very useful script for all writers . . . . . . . . . . . . . . . . . . . .
Read Fortran 90 files with namelists . . . . . . . . . . . . . . . . . .
Automatic update of function calls in C++ files . . . . . . .
Read/write (x, y) pairs from/to binary files . . . . . . . . . . . .
Use the XDR format in the script from Exercise 8.21 . . .
Archive all files needed in a L A TEX document . . . . . . . . . .
Using a web site for distributed simulation . . . . . . . . . . . .
Convert data structures to/from strings . . . . . . . . . . . . . . .
Implement a class for vectors in 3D . . . . . . . . . . . . . . . . . .
Extend the class from Exericse 8.26 . . . . . . . . . . . . . . . . . .
Make a tuple with cyclic indices . . . . . . . . . . . . . . . . . . . . .
Make a dictionary type with ordered keys . . . . . . . . . . . . .
Make a smarter integration function . . . . . . . . . . . . . . . . . .
Equip class Grid2D with subscripting . . . . . . . . . . . . . . . . .
Extend the functionality of class Grid2D . . . . . . . . . . . . . . .
Make a boundary iterator in a 2D grid . . . . . . . . . . . . . . . .
Make a generator for odd numbers . . . . . . . . . . . . . . . . . . .
Make a class for sparse vectors . . . . . . . . . . . . . . . . . . . . . . .
Extend Exercise 5.1 with a callback to Python . . . . . . . . .
Compile callback functions in Exercise 9.1 . . . . . . . . . . . . .
Smoothing of time series . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Smoothing of 3D data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Type incompatibility between Python and Fortran . . . . .
Problematic callbacks to Python from Fortran . . . . . . . . .
Array look-up efficiency: Python vs. Fortran . . . . . . . . . . .
Extend Exercise 5.2 or 5.3 with a callback to Python . . .
Investigate the efficiency of vector operations . . . . . . . . . .
Debug a C extension module . . . . . . . . . . . . . . . . . . . . . . . .
Make callbacks to vectorized Python functions . . . . . . . . .
Avoid Python callbacks in extension modules . . . . . . . . . .
Extend Exercise 9.4 with C and C++ code . . . . . . . . . . . .

List of Exercises
Exercise 10.7 Apply SWIG to an array class in C++ . . . . . . . . . . . . . . .
Exercise 10.8 Build a dictionary in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Exercise 10.9 Make a C module for computing random numbers . . . . . .
Exercise 10.10 Almost automatic generation of C extension modules . . .
Exercise 10.11 Introduce C++ array objects in Exercise 10.10 . . . . . . . .
Exercise 10.12 Introduce SCXX in Exercise 10.11 . . . . . . . . . . . . . . . . . . .
Exercise 11.1 Incorporate a BLT graph widget in simviz1.py . . . . . . . . .
Exercise 11.2 Plot a two-column datafile in a Pmw.Blt widget . . . . . . .
Exercise 11.3 Use a BLT graph widget in simvizGUI2.py . . . . . . . . . . . . .
Exercise 11.4 Extend Exercise 11.3 to handle multiple curves . . . . . . . .
Exercise 11.5 Use a BLT graph widget in Exercise 6.4 . . . . . . . . . . . . . .
Exercise 11.6 Interactive dump of snapshot plots in an animation . . . .
Exercise 11.7 Extend the animate.py GUI . . . . . . . . . . . . . . . . . . . . . . . . .
Exercise 11.8 Animate a curve in a BLT graph widget . . . . . . . . . . . . . .
Exercise 11.9 Add animations to the GUI in Exercise 11.5 . . . . . . . . . . .
Exercise 11.10 Extend the GUI in Exercise 6.17 with a fancy list . . . . . .
Exercise 11.11 Remove canvas items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Exercise 11.12 Introduce properties in class Parameters . . . . . . . . . . . . . . .
Exercise 11.13 Convert command file into Python objects . . . . . . . . . . . .
Exercise 12.1 Allow multiple values of parameters in input files . . . . . .
Exercise 12.2 Turn mathematical formulas into Fortran functions . . . . .
Exercise 12.3 Move a wave source during simulation . . . . . . . . . . . . . . . .
Exercise 12.4 Include damping in a 1D wave simulator . . . . . . . . . . . . . .
Exercise 12.5 Add a NumPy database to a PDE simulator . . . . . . . . . . .
Exercise 12.6 Use iterators in finite difference schemes . . . . . . . . . . . . . .
Exercise 12.7 Set vectorized boundary conditions in 3D grids . . . . . . . .
Exercise B.1 Make a Python module of simviz1.py . . . . . . . . . . . . . . . .
Exercise B.2 Pack modules and packages using Distutils . . . . . . . . . . . .
Exercise B.3 Distribute mixed-language code using Distutils . . . . . . . .
Exercise B.4 Use tools to document the script in Exercise 3.14 . . . . . .
Exercise B.5 Make a regression test for a trivial script . . . . . . . . . . . . . .
Exercise B.6 Repeat Exercise B.5 using the test script tools . . . . . . . . .
Exercise B.7 Make a regression test for a script with I/O . . . . . . . . . . .
Exercise B.8 Make a regression test for the script in Exercise 3.14 . . .
Exercise B.9 Approximate floats in Exercise B.5 . . . . . . . . . . . . . . . . . . .
Exercise B.10 Make tests for grid iterators . . . . . . . . . . . . . . . . . . . . . . . . .
Exercise B.11 Make a tar/zip archive of files associated with a script . .
Exercise B.12 Semi-automatic evaluation of a student project . . . . . . . .
Правила, инструкции, FAQ!!!
Торрент   Скачать торрент Магнет ссылка
Скачать торрент
[ Размер 4.47 КБ / Просмотров 62 ]

Статус
Проверен 
 
Размер  6.31 МБ
Приватный: Нет (DHT включён)
.torrent скачан  1
Как залить торрент? | Как скачать Torrent? | Ошибка в торренте? Качайте магнет  


     Отправить личное сообщение
   
Страница 1 из 1
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему


Сейчас эту тему просматривают: нет зарегистрированных пользователей и гости: 1


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Перейти:  
Ресурс не предоставляет электронные версии произведений, а занимается лишь коллекционированием и каталогизацией ссылок, присылаемых и публикуемых на форуме нашими читателями. Если вы являетесь правообладателем какого-либо представленного материала и не желаете чтобы ссылка на него находилась в нашем каталоге, свяжитесь с нами и мы незамедлительно удалим её. Файлы для обмена на трекере предоставлены пользователями сайта, и администрация не несёт ответственности за их содержание. Просьба не заливать файлы, защищенные авторскими правами, а также файлы нелегального содержания!