SciPy Reference Guide
Release 1.4.1
Written by the SciPy community
December 19, 2019
CONTENTS
1 Installing and upgrading 3
2 SciPy API 5
2.1 Importing from SciPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Guidelines for importing functions from SciPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 API definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 SciPy structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 Release Notes 9
3.1 SciPy 1.4.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 SciPy 1.4.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 SciPy 1.3.2 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.4 SciPy 1.3.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.5 SciPy 1.3.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.6 SciPy 1.2.2 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.7 SciPy 1.2.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.8 SciPy 1.2.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.9 SciPy 1.1.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.10 SciPy 1.0.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.11 SciPy 1.0.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
3.12 SciPy 0.19.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
3.13 SciPy 0.19.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
3.14 SciPy 0.18.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
3.15 SciPy 0.18.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
3.16 SciPy 0.17.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
3.17 SciPy 0.17.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
3.18 SciPy 0.16.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
3.19 SciPy 0.16.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
3.20 SciPy 0.15.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
3.21 SciPy 0.15.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
3.22 SciPy 0.14.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
3.23 SciPy 0.14.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
3.24 SciPy 0.13.2 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
3.25 SciPy 0.13.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
3.26 SciPy 0.13.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
3.27 SciPy 0.12.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
3.28 SciPy 0.12.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
3.29 SciPy 0.11.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
3.30 SciPy 0.10.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
3.31 SciPy 0.10.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
i
3.32 SciPy 0.9.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
3.33 SciPy 0.8.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
3.34 SciPy 0.7.2 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
3.35 SciPy 0.7.1 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
3.36 SciPy 0.7.0 Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
4 Tutorial 247
4.1 SciPy Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
4.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
4.1.2 Basic functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
4.1.3 Special functions (scipy.special) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
4.1.4 Integration (scipy.integrate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
4.1.5 Optimization (scipy.optimize) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
4.1.6 Interpolation (scipy.interpolate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
4.1.7 Fourier Transforms (scipy.fft) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
4.1.8 Signal Processing (scipy.signal) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
4.1.9 Linear Algebra (scipy.linalg) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
4.1.10 Sparse eigenvalue problems with ARPACK . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
4.1.11 Compressed Sparse Graph Routines (scipy.sparse.csgraph) . . . . . . . . . . . . . 354
4.1.12 Spatial data structures and algorithms (scipy.spatial) . . . . . . . . . . . . . . . . . . 357
4.1.13 Statistics (scipy.stats) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364
4.1.14 Multidimensional image processing (scipy.ndimage) . . . . . . . . . . . . . . . . . . . 450
4.1.15 File IO (scipy.io) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
5 Developer Documentation 483
5.1 SciPy Code of Conduct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
5.2 Ways to Contribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
5.3 SciPy contributor guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
5.4 SciPy Roadmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
5.5 Detailed SciPy Roadmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
5.6 Toolchain Roadmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
5.7 SciPy Core Developer Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502
5.8 Deciding on new features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 502
5.9 SciPy Project Governance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
5.10 Development environment quickstart guide (macOS) . . . . . . . . . . . . . . . . . . . . . . . . . . 518
5.11 Development environment quickstart guide (Ubuntu 16.04) . . . . . . . . . . . . . . . . . . . . . . . 520
5.12 Development workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
5.13 PEP8 and SciPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
5.14 Rendering Documentation with Sphinx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
5.15 Running SciPy Tests Locally . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
5.16 Benchmarking SciPy with airspeed velocity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
5.17 Adding Cython to SciPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
5.18 Adding New Methods, Functions, and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
6 API Reference 537
6.1 Clustering package (scipy.cluster) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
6.2 K-means clustering and vector quantization (scipy.cluster.vq) . . . . . . . . . . . . . . . . . 537
6.3 Hierarchical clustering (scipy.cluster.hierarchy) . . . . . . . . . . . . . . . . . . . . . . . 544
6.4 Constants (scipy.constants) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
6.5 Discrete Fourier transforms (scipy.fft) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
6.6 Legacy discrete Fourier transforms (scipy.fftpack) . . . . . . . . . . . . . . . . . . . . . . . . 648
6.7 Integration and ODEs (scipy.integrate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
6.8 Interpolation (scipy.interpolate) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
6.9 Input and output (scipy.io) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 835
ii
6.10 Linear algebra (scipy.linalg) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857
6.11 Low-level BLAS functions (scipy.linalg.blas) . . . . . . . . . . . . . . . . . . . . . . . . . 962
6.12 Low-level LAPACK functions (scipy.linalg.lapack) . . . . . . . . . . . . . . . . . . . . . . 1026
6.13 BLAS Functions for Cython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1228
6.14 LAPACK functions for Cython . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1233
6.15 Interpolative matrix decomposition (scipy.linalg.interpolative) . . . . . . . . . . . . . . 1274
6.16 Miscellaneous routines (scipy.misc) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1284
6.17 Multi-dimensional image processing (scipy.ndimage) . . . . . . . . . . . . . . . . . . . . . . . 1290
6.18 Orthogonal distance regression (scipy.odr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1380
6.19 Optimization and Root Finding (scipy.optimize) . . . . . . . . . . . . . . . . . . . . . . . . . 1390
6.20 Nonlinear solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1525
6.21 Cython Optimize Zeros API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1527
6.22 Signal processing (scipy.signal) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1530
6.23 Sparse matrices (scipy.sparse) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1758
6.24 Sparse linear algebra (scipy.sparse.linalg) . . . . . . . . . . . . . . . . . . . . . . . . . . . 1896
6.25 Compressed Sparse Graph Routines (scipy.sparse.csgraph) . . . . . . . . . . . . . . . . . . 1938
6.26 Spatial algorithms and data structures (scipy.spatial) . . . . . . . . . . . . . . . . . . . . . . . 1968
6.27 Distance computations (
scipy.spatial.distance
) . . . . . . . . . . . . . . . . . . . . . . . 2007
6.28 Special functions (scipy.special) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2032
6.29 Statistical functions (scipy.stats) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2230
6.30 Low-level callback functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2726
Bibliography 2729
Index 2763
iii
评论0