NumPy Reference - SciPy

NumPy Reference

Release 1.10.0

Written by the NumPy community

October 18, 2015

CONTENTS

1

2

3

Array objects

1.1 The N-dimensional array (ndarray)

1.2 Scalars . . . . . . . . . . . . . . . .

1.3 Data type objects (dtype) . . . . . .

1.4 Indexing . . . . . . . . . . . . . . .

1.5 Iterating Over Arrays . . . . . . . . .

1.6 Standard array subclasses . . . . . .

1.7 Masked arrays . . . . . . . . . . . .

1.8 The Array Interface . . . . . . . . .

1.9 Datetimes and Timedeltas . . . . . .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

3

3

73

90

105

112

123

248

440

444

Universal functions (ufunc)

2.1 Broadcasting . . . . . . . .

2.2 Output type determination .

2.3 Use of internal buffers . . .

2.4 Error handling . . . . . . .

2.5 Casting Rules . . . . . . . .

2.6 Overriding Ufunc behavior .

2.7 ufunc . . . . . . . . . . .

2.8 Available ufuncs . . . . . .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

453

453

454

454

454

457

459

459

469

Routines

3.1 Array creation routines . . . . . . . . . . . . . . . . . . . . . . .

3.2 Array manipulation routines . . . . . . . . . . . . . . . . . . . .

3.3 Binary operations . . . . . . . . . . . . . . . . . . . . . . . . . .

3.4 String operations . . . . . . . . . . . . . . . . . . . . . . . . . .

3.5 C-Types Foreign Function Interface (numpy.ctypeslib) . . .

3.6 Datetime Support Functions . . . . . . . . . . . . . . . . . . . .

3.7 Data type routines . . . . . . . . . . . . . . . . . . . . . . . . .

3.8 Optionally Scipy-accelerated routines (numpy.dual) . . . . . .

3.9 Mathematical functions with automatic domain (numpy.emath)

3.10 Floating point error handling . . . . . . . . . . . . . . . . . . . .

3.11 Discrete Fourier Transform (numpy.fft) . . . . . . . . . . . .

3.12 Financial functions . . . . . . . . . . . . . . . . . . . . . . . . .

3.13 Functional programming . . . . . . . . . . . . . . . . . . . . . .

3.14 Numpy-specific help functions . . . . . . . . . . . . . . . . . . .

3.15 Indexing routines . . . . . . . . . . . . . . . . . . . . . . . . . .

3.16 Input and output . . . . . . . . . . . . . . . . . . . . . . . . . .

3.17 Linear algebra (numpy.linalg) . . . . . . . . . . . . . . . .

3.18 Logic functions . . . . . . . . . . . . . . . . . . . . . . . . . . .

3.19 Masked array operations . . . . . . . . . . . . . . . . . . . . . .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

473

473

510

553

561

606

607

612

631

632

632

639

663

673

678

681

714

740

777

795

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

i

3.20

3.21

3.22

3.23

3.24

3.25

3.26

3.27

3.28

3.29

3.30

Mathematical functions . . . . . . . .

Matrix library (numpy.matlib) . . .

Miscellaneous routines . . . . . . . . .

Padding Arrays . . . . . . . . . . . . .

Polynomials . . . . . . . . . . . . . .

Random sampling (numpy.random)

Set routines . . . . . . . . . . . . . . .

Sorting, searching, and counting . . . .

Statistics . . . . . . . . . . . . . . . .

Test Support (numpy.testing) . . .

Window functions . . . . . . . . . . .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

922

988

993

995

998

1174

1273

1278

1295

1327

1341

4

Packaging (numpy.distutils)

1349

4.1 Modules in numpy.distutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1349

4.2 Building Installable C libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1360

4.3 Conversion of .src files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1361

5

Numpy C-API

5.1 Python Types and C-Structures . .

5.2 System configuration . . . . . . . .

5.3 Data Type API . . . . . . . . . . .

5.4 Array API . . . . . . . . . . . . .

5.5 Array Iterator API . . . . . . . . .

5.6 UFunc API . . . . . . . . . . . . .

5.7 Generalized Universal Function API

5.8 Numpy core libraries . . . . . . . .

5.9 C API Deprecations . . . . . . . .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1363

1363

1376

1377

1382

1422

1439

1445

1448

1453

6

Numpy internals

1455

6.1 Numpy C Code Explanations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1455

6.2 Internal organization of numpy arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1462

6.3 Multidimensional Array Indexing Order Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1462

7

Numpy and SWIG

1465

7.1 Numpy.i: a SWIG Interface File for NumPy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1465

7.2 Testing the numpy.i Typemaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1480

8

Acknowledgements

1483

Bibliography

1485

Index

1495

ii

NumPy Reference, Release 1.10.0

Release

1.10

Date

October 18, 2015

This reference manual details functions, modules, and objects included in Numpy, describing what they are and what

they do. For learning how to use NumPy, see also user.

CONTENTS

1

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download