NumPy Reference

NumPy Reference

Release 1.15.4

Written by the NumPy community

November 04, 2018

CONTENTS

1

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 . . . . . .

2

Constants

3

Universal functions (ufunc)

3.1 Broadcasting . . . . . . . .

3.2 Output type determination .

3.3 Use of internal buffers . . .

3.4 Error handling . . . . . . .

3.5 Casting Rules . . . . . . . .

3.6 Overriding Ufunc behavior .

3.7 ufunc . . . . . . . . . . .

3.8 Available ufuncs . . . . . .

4

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

3

.

3

. 46

. 62

. 77

. 85

. 97

. 201

. 349

. 353

363

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

371

371

372

372

373

375

377

377

389

Routines

4.1 Array creation routines . . . . . . . . . . . . . . . . . . . . . . .

4.2 Array manipulation routines . . . . . . . . . . . . . . . . . . . .

4.3 Binary operations . . . . . . . . . . . . . . . . . . . . . . . . . .

4.4 String operations . . . . . . . . . . . . . . . . . . . . . . . . . .

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

4.6 Datetime Support Functions . . . . . . . . . . . . . . . . . . . .

4.7 Data type routines . . . . . . . . . . . . . . . . . . . . . . . . .

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

4.9 Mathematical functions with automatic domain (numpy.emath)

4.10 Floating point error handling . . . . . . . . . . . . . . . . . . . .

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

4.12 Financial functions . . . . . . . . . . . . . . . . . . . . . . . . .

4.13 Functional programming . . . . . . . . . . . . . . . . . . . . . .

4.14 NumPy-specific help functions . . . . . . . . . . . . . . . . . . .

4.15 Indexing routines . . . . . . . . . . . . . . . . . . . . . . . . . .

4.16 Input and output . . . . . . . . . . . . . . . . . . . . . . . . . .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

395

395

430

470

478

518

520

526

540

541

542

546

568

577

584

587

624

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

i

4.17

4.18

4.19

4.20

4.21

4.22

4.23

4.24

4.25

4.26

4.27

4.28

4.29

Linear algebra (numpy.linalg) . .

Logic functions . . . . . . . . . . . . .

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 . . . . . . . . . . .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

650

692

714

799

805

808

811

987

1098

1103

1117

1158

1178

5

Packaging (numpy.distutils)

1187

5.1 Modules in numpy.distutils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1187

5.2 Building Installable C libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1197

5.3 Conversion of .src files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1199

6

NumPy C-API

6.1 Python Types and C-Structures . .

6.2 System configuration . . . . . . . .

6.3 Data Type API . . . . . . . . . . .

6.4 Array API . . . . . . . . . . . . .

6.5 Array Iterator API . . . . . . . . .

6.6 UFunc API . . . . . . . . . . . . .

6.7 Generalized Universal Function API

6.8 NumPy core libraries . . . . . . . .

6.9 C API Deprecations . . . . . . . .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1201

1201

1215

1217

1221

1262

1279

1284

1286

1292

7

NumPy internals

1295

7.1 NumPy C Code Explanations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1295

7.2 Internal organization of numpy arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1302

7.3 Multidimensional Array Indexing Order Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1303

8

NumPy and SWIG

1305

8.1 Testing the numpy.i Typemaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1320

9

Acknowledgements

1323

Bibliography

1325

Python Module Index

1335

Index

1337

ii

NumPy Reference, Release 1.15.4

Release 1.15

Date November 04, 2018

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