Navigation
index
modules
|
next
|
Numpy and Scipy Documentation
»
Numpy manual contents
ΒΆ
Numpy User Guide
How to find documentation
Numpy basics
Data types
Array types and conversions between types
Array Scalars
Array creation
Introduction
Converting Python array_like Objects to Numpy Arrays
Intrinsic Numpy Array Creation
Reading Arrays From Disk
Standard Binary Formats
Common ASCII Formats
Custom Binary Formats
Use of Special Libraries
Indexing
Assignment vs referencing
Single element indexing
Other indexing options
Index arrays
Indexing Multi-dimensional arrays
Boolean or “mask” index arrays
Combining index arrays with slices
Structural indexing tools
Assigning values to indexed arrays
Dealing with variable numbers of indices within programs
Broadcasting
General Broadcasting Rules
Structured arrays (aka “Record arrays”)
Structured Arrays (aka Record Arrays)
Introduction
Defining Structured Arrays
Accessing and modifying field names
Accessing field titles
Subclassing ndarray
Credits
Introduction
ndarrays and object creation
__new__
and
__init__
Simple example - adding an extra attribute to ndarray
Slightly more realistic example - attribute added to existing array
__array_wrap__
for ufuncs
Extra gotchas - custom __del__ methods and ndarray.base
Performance
Miscellaneous
IEEE 754 Floating Point Special Values:
Examples:
Interfacing to C:
Interfacing to Fortran:
Interfacing to C++:
Methods vs. Functions
Using Numpy C-API
How to extend NumPy
Writing an extension module
Required subroutine
Defining functions
Functions without keyword arguments
Functions with keyword arguments
Reference counting
Dealing with array objects
Converting an arbitrary sequence object
Creating a brand-new ndarray
Getting at ndarray memory and accessing elements of the ndarray
Example
Using Python as glue
Calling other compiled libraries from Python
Hand-generated wrappers
f2py
Creating source for a basic extension module
Creating a compiled extension module
Improving the basic interface
Inserting directives in Fortran source
A filtering example
Calling f2py from Python
Automatic extension module generation
Conclusion
weave
Speed up code involving arrays (also see scipy.numexpr)
Inline C-code
Simplify creation of an extension module
Conclusion
Pyrex
Pyrex-add
Pyrex-filter
Conclusion
ctypes
Having a shared library
Loading the shared library
Converting arguments
Calling the function
Complete example
Conclusion
Additional tools you may find useful
SWIG
SIP
Boost Python
Instant
PyInline
PyFort
Beyond the Basics
Iterating over elements in the array
Basic Iteration
Iterating over all but one axis
Iterating over multiple arrays
Broadcasting over multiple arrays
Creating a new universal function
User-defined data-types
Adding the new data-type
Registering a casting function
Registering coercion rules
Registering a ufunc loop
Subtyping the ndarray in C
Creating sub-types
Specific features of ndarray sub-typing
The __array_finalize__ method
The __array_priority__ attribute
The __array_wrap__ method
NumPy Reference
Array objects
The N-dimensional array (
ndarray
)
Constructing arrays
Indexing arrays
Internal memory layout of an ndarray
Array attributes
Memory layout
Data type
Other attributes
Array interface
ctypes
foreign function interface
Array methods
Array conversion
Shape manipulation
Item selection and manipulation
Calculation
Arithmetic and comparison operations
Special methods
Scalars
Built-in scalar types
Attributes
Indexing
Methods
Defining new types
Data type objects (
dtype
)
Specifying and constructing data types
dtype
Attributes
Methods
Indexing
Basic Slicing
Advanced indexing
Integer
Boolean
Record Access
Flat Iterator indexing
Standard array subclasses
Special attributes and methods
Matrix objects
Memory-mapped file arrays
Character arrays (
numpy.char
)
Record arrays (
numpy.rec
)
Masked arrays (
numpy.ma
)
Standard container class
Array Iterators
Default iteration
Flat iteration
N-dimensional enumeration
Iterator for broadcasting
Masked arrays
The
numpy.ma
module
Rationale
What is a masked array?
The
numpy.ma
module
Using numpy.ma
Constructing masked arrays
Accessing the data
Accessing the mask
Accessing only the valid entries
Modifying the mask
Masking an entry
Unmasking an entry
Indexing and slicing
Operations on masked arrays
Examples
Data with a given value representing missing data
Filling in the missing data
Numerical operations
Ignoring extreme values
Constants of the
numpy.ma
module
The
MaskedArray
class
Attributes and properties of masked arrays
MaskedArray
methods
Conversion
Shape manipulation
Item selection and manipulation
Pickling and copy
Calculations
Arithmetic and comparison operations
Comparison operators:
Truth value of an array (
bool
):
Arithmetic:
Arithmetic, in-place:
Representation
Special methods
Specific methods
Handling the mask
Handling the
fill_value
Counting the missing elements
Masked array operations
Constants
Creation
From existing data
Ones and zeros
Inspecting the array
Manipulating a MaskedArray
Changing the shape
Modifying axes
Changing the number of dimensions
Joining arrays
Operations on masks
Creating a mask
Accessing a mask
Finding masked data
Modifying a mask
Conversion operations
> to a masked array
> to a ndarray
> to another object
Pickling and unpickling
Filling a masked array
Masked arrays arithmetics
Arithmetics
Minimum/maximum
Sorting
Algebra
Polynomial fit
Clipping and rounding
Miscellanea
The Array Interface
Python side
C-struct access
Universal functions (
ufunc
)
Broadcasting
Output type determination
Use of internal buffers
Error handling
Casting Rules
ufunc
Optional keyword arguments
Attributes
Methods
Available ufuncs
Math operations
Trigonometric functions
Bit-twiddling functions
Comparison functions
Floating functions
Routines
Array creation routines
Ones and zeros
From existing data
Creating record arrays (
numpy.rec
)
Creating character arrays (
numpy.char
)
Numerical ranges
Building matrices
The Matrix class
Array manipulation routines
Changing array shape
Transpose-like operations
Changing number of dimensions
Changing kind of array
Joining arrays
Splitting arrays
Tiling arrays
Adding and removing elements
Rearranging elements
Indexing routines
Generating index arrays
Indexing-like operations
Inserting data into arrays
Iterating over arrays
Data type routines
Creating data types
Data type information
Data type testing
Miscellaneous
Input and output
NPZ files
Text files
String formatting
Memory mapping files
Text formatting options
Base-n representations
Data sources
Fourier transforms (
numpy.fft
)
1-dimensional
2-dimensional
N-dimensional
Hermite symmetric
Real-valued
Helper routines
Linear algebra (
numpy.linalg
)
Matrix and vector products
Decompositions
Matrix eigenvalues
Norms and other numbers
Solving equations and inverting matrices
Exceptions
Random sampling (
numpy.random
)
Simple random data
Permutations
Distributions
Random generator
Sorting and searching
Sorting
Searching
Logic functions
Truth value testing
Array contents
Array type testing
Logical operations
Comparison
Binary operations
Elementwise bit operations
Bit packing
Output formatting
Statistics
Extremal values
Averages and variances
Correlating
Histograms
Mathematical functions
Trigonometric functions
Hyperbolic functions
Rounding
Sums, products, differences
Exponents and logarithms
Other special functions
Floating point routines
Arithmetic operations
Handling complex numbers
Miscellaneous
Functional programming
Polynomials
Basics
Fitting
Calculus
Arithmetic
Warnings
Financial functions
Simple financial functions
Set routines
Making proper sets
Boolean operations
Window functions
Various windows
Floating point error handling
Setting and getting error handling
Internal functions
Masked array operations
Constants
Creation
From existing data
Ones and zeros
Inspecting the array
Manipulating a MaskedArray
Changing the shape
Modifying axes
Changing the number of dimensions
Joining arrays
Operations on masks
Creating a mask
Accessing a mask
Finding masked data
Modifying a mask
Conversion operations
> to a masked array
> to a ndarray
> to another object
Pickling and unpickling
Filling a masked array
Masked arrays arithmetics
Arithmetics
Minimum/maximum
Sorting
Algebra
Polynomial fit
Clipping and rounding
Miscellanea
Numpy-specific help functions
Finding help
Reading help
Miscellaneous routines
Buffer objects
Performance tuning
Mathematical functions with automatic domain (
numpy.emath
)
Matrix library (
numpy.matlib
)
Optionally Scipy-accelerated routines (
numpy.dual
)
Linear algebra
FFT
Other
Numarray compatibility (
numpy.numarray
)
Old Numeric compatibility (
numpy.oldnumeric
)
C-Types Foreign Function Interface (
numpy.ctypeslib
)
Packaging (
numpy.distutils
)
Modules in
numpy.distutils
misc_util
Other modules
Conversion of
.src
files
Fortran files
Named repeat rule
Short repeat rule
Pre-defined names
Other files
Numpy C-API
Python Types and C-Structures
New Python Types Defined
PyArray_Type
PyArrayDescr_Type
PyUFunc_Type
PyArrayIter_Type
PyArrayMultiIter_Type
PyArrayFlags_Type
ScalarArrayTypes
Other C-Structures
PyArray_Dims
PyArray_Chunk
PyArrayInterface
Internally used structures
Configuration defines
Guaranteed to be defined
Data Type API
Enumerated Types
Defines
Max and min values for integers
Number of bits in data types
Bit-width references to enumerated typenums
Integer that can hold a pointer
C-type names
Boolean
(Un)Signed Integer
(Complex) Floating point
Bit-width names
Printf Formatting
Array API
Array structure and data access
Data access
Creating arrays
From scratch
From other objects
Dealing with types
General check of Python Type
Data-type checking
Converting data types
New data types
Special functions for PyArray_OBJECT
Array flags
Basic Array Flags
Combinations of array flags
Flag-like constants
Flag checking
Array method alternative API
Conversion
Shape Manipulation
Item selection and manipulation
Calculation
Functions
Array Functions
Other functions
Array Iterators
Broadcasting (multi-iterators)
Array Scalars
Data-type descriptors
Conversion Utilities
For use with
PyArg_ParseTuple
Other conversions
Miscellaneous
Importing the API
Internal Flexibility
Memory management
Threading support
Group 1
Group 2
Priority
Default buffers
Other constants
Miscellaneous Macros
Enumerated Types
UFunc API
Constants
Macros
Functions
Generic functions
Importing the API
Numpy core libraries
Numpy core math library
Floating point classification
Useful math constants
Numpy internals
Numpy C Code Explanations
Memory model
Data-type encapsulation
N-D Iterators
Broadcasting
Array Scalars
Advanced (“Fancy”) Indexing
Fancy-indexing check
Fancy-indexing implementation
Creating the mapping object
Binding the mapping object
Getting (or Setting)
Universal Functions
Setup
Function call
One Loop
Strided Loop
Buffered Loop
Final output manipulation
Methods
Setup
Reduce
Accumulate
Reduceat
Internal organization of numpy arrays
Multidimensional Array Indexing Order Issues
Acknowledgements
Release Notes
NumPy 1.3.0 Release Notes
Highlights
Python 2.6 support
Generalized ufuncs
Experimental Windows 64 bits support
New features
Formatting issues
Nan handling in max/min
Nan handling in sign
New ufuncs
Masked arrays
gfortran support on windows
Arch option for windows binary
Deprecated features
Histogram
Documentation changes
New C API
Multiarray API
Ufunc API
New defines
Portable NAN, INFINITY, etc...
Internal changes
numpy.core math configuration revamp
umath refactor
Improvements to build warnings
Separate core math library
CPU arch detection
About NumPy
NumPy community
About this documentation
Conventions
Reporting bugs
Numpy License
Glossary
Jargon
Next topic
Numpy User Guide
This Page
Show Source
Edit page
Quick search
Navigation
index
modules
|
next
|
Numpy and Scipy Documentation
»