David Ascher
Paul F. Dubois
Konrad Hinsen
Jim Hugunin
Travis Oliphant
with contributions from the Numerical Python community.
Lawrence Livermore National Laboratory, Livermore, CA 94566
Please see file Legal.html in the source distribution.
This open source project has been contributed to by many people, including personnel of the Lawrence Livermore National Laboratory. The following notice covers those contributions including this manual.
Copyright (c) 1999, 2000, 2001. The Regents of the University of California. All rights reserved.
Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software.
This work was produced at the University of California, Lawrence Livermore National Laboratory under contract no. W-7405-ENG-48 between the U.S. Department of Energy and The Regents of the University of California for the operation of UC LLNL.
This software was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, or assumes any liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately-owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes.
Where to get information and code 3
Testing the Python installation 5
Testing the Numeric Python Extension Installation 5
Possible reasons for failure 8
Creating arrays from scratch 13
Creating arrays with values specified `on-the-fly' 18
Creating an array from a function: fromfunction() 20
Automatic Coercions and Binary Operations 21
Deliberate up-casting: The asarray function 22
Consequences of silent upcasting 23
Deliberate casts (potentially down): the astype method 23
Getting and Setting array values 25
Ufuncs can operate on any Python sequence 29
Ufuncs can take output arguments 29
Ufuncs have special methods 29
The accumulate ufunc method 30
Ufuncs always return new arrays 31
Unary Mathematical Ufuncs (take only one argument) 31
The operators and the comparison functions are not exactly equivalent 32
compress(condition, a, axis=0) 39
diagonal(a, k=0, axis1=0, axis2 = 1) 39
argmax(a, axis=-1), argmin(a, axis=-1) 41
fromstring(string, typecode) 41
indices(shape, typecode=None) 42
concatenate((a0, a1, ... , an), axis=0) 43
diagonal(a, offset=0, axis1=0, axis2=1) 44
cross_correlate (a, v, mode=0) 45
allclose (x, y, rtol = 1.e-5, atol = 1.e-8) 46
real and imaginary 49
eye(N, M=N, k=0, typecode=None) 52
tri(N, M=N, k=0, typecode=None) 53
Indexing in and out, slicing 55
Set-indexing and Broadcasting 56
Textual representations of arrays 57
Dealing with floating point exceptions 59
Writing a C extension to NumPy 61
Preparing an extension module for NumPy arrays 61
Accessing NumPy arrays from C 62
Types and Internal Structure 62
Accepting input data from any sequence type 64
Returning arrays from C functions 65
ArrayObject C Structure and API 68
License and disclaimer for packages MA, RNG, Properties 80
inverse_fft(data, n=None, axis=-1) 81
real_fft(data, n=None, axis=-1) 81
inverse_real_fft(data, n=None, axis=-1) 82
fft2d(data, s=None, axes=(-2,-1)) 82
real_fft2d(data, s=None, axes=(-2,-1)) 82
solve_linear_equations(a, b) 84
singular_value_decomposition(a, full_matrices=0) 85
generalized_inverse(a, rcond=1e-10) 85
linear_least_squares(a, b, rcond=e-10) 85
random(shape= ReturnFloat ) 87
uniform(minimum, maximum, shape=ReturnFloat) 87
randint(minimum, maximum, shape=ReturnFloat) 87
Floating point random arrays 88
standard_normal (shape=ReturnFloat) 88
normal (mean, stddev, shape=ReturnFloat) 88
multivariate_normal (mean, covariance) or
multivariate_normal (mean, covariance, leadingAxesShape) 88
exponential (mean, shape=ReturnFloat) 88
beta (a, b, shape=ReturnFloat) 88
gamma (a, r, shape=ReturnFloat) 89
chi_square (df, shape=ReturnFloat) 89
noncentral_chi_square (df, nonc, shape=ReturnFloat) 89
F (dfn, dfd, shape=ReturnFloat) 89
noncentral_F (dfn, dfd, nconc, shape=ReturnFloat) 89
binomial (trials, prob, shape=ReturnInt) 89
negative_binomial (trials, prob, shape=ReturnInt) 89
poisson (mean, shape=ReturnInt) 89
multinomial (trials, probs) or multinomial (trials, probs, leadingAxesShape) 89
Attributes of masked arrays 98
Constructing masked arrays 101
Operations that produce a scalar result 104
Assignment to elements and slices 104
Controlling the size of the string representations 107
The constant masked_print_option 108
Example of masked behavior 108
Class masked_unary_function 108
Class masked_binary_function 109
Class domained_binary_function 109
Data with a given value representing missing data 109
Filling in the missing data 109