Chris@87
|
1 """
|
Chris@87
|
2 Basic functions used by several sub-packages and
|
Chris@87
|
3 useful to have in the main name-space.
|
Chris@87
|
4
|
Chris@87
|
5 Type Handling
|
Chris@87
|
6 -------------
|
Chris@87
|
7 ================ ===================
|
Chris@87
|
8 iscomplexobj Test for complex object, scalar result
|
Chris@87
|
9 isrealobj Test for real object, scalar result
|
Chris@87
|
10 iscomplex Test for complex elements, array result
|
Chris@87
|
11 isreal Test for real elements, array result
|
Chris@87
|
12 imag Imaginary part
|
Chris@87
|
13 real Real part
|
Chris@87
|
14 real_if_close Turns complex number with tiny imaginary part to real
|
Chris@87
|
15 isneginf Tests for negative infinity, array result
|
Chris@87
|
16 isposinf Tests for positive infinity, array result
|
Chris@87
|
17 isnan Tests for nans, array result
|
Chris@87
|
18 isinf Tests for infinity, array result
|
Chris@87
|
19 isfinite Tests for finite numbers, array result
|
Chris@87
|
20 isscalar True if argument is a scalar
|
Chris@87
|
21 nan_to_num Replaces NaN's with 0 and infinities with large numbers
|
Chris@87
|
22 cast Dictionary of functions to force cast to each type
|
Chris@87
|
23 common_type Determine the minimum common type code for a group
|
Chris@87
|
24 of arrays
|
Chris@87
|
25 mintypecode Return minimal allowed common typecode.
|
Chris@87
|
26 ================ ===================
|
Chris@87
|
27
|
Chris@87
|
28 Index Tricks
|
Chris@87
|
29 ------------
|
Chris@87
|
30 ================ ===================
|
Chris@87
|
31 mgrid Method which allows easy construction of N-d
|
Chris@87
|
32 'mesh-grids'
|
Chris@87
|
33 ``r_`` Append and construct arrays: turns slice objects into
|
Chris@87
|
34 ranges and concatenates them, for 2d arrays appends rows.
|
Chris@87
|
35 index_exp Konrad Hinsen's index_expression class instance which
|
Chris@87
|
36 can be useful for building complicated slicing syntax.
|
Chris@87
|
37 ================ ===================
|
Chris@87
|
38
|
Chris@87
|
39 Useful Functions
|
Chris@87
|
40 ----------------
|
Chris@87
|
41 ================ ===================
|
Chris@87
|
42 select Extension of where to multiple conditions and choices
|
Chris@87
|
43 extract Extract 1d array from flattened array according to mask
|
Chris@87
|
44 insert Insert 1d array of values into Nd array according to mask
|
Chris@87
|
45 linspace Evenly spaced samples in linear space
|
Chris@87
|
46 logspace Evenly spaced samples in logarithmic space
|
Chris@87
|
47 fix Round x to nearest integer towards zero
|
Chris@87
|
48 mod Modulo mod(x,y) = x % y except keeps sign of y
|
Chris@87
|
49 amax Array maximum along axis
|
Chris@87
|
50 amin Array minimum along axis
|
Chris@87
|
51 ptp Array max-min along axis
|
Chris@87
|
52 cumsum Cumulative sum along axis
|
Chris@87
|
53 prod Product of elements along axis
|
Chris@87
|
54 cumprod Cumluative product along axis
|
Chris@87
|
55 diff Discrete differences along axis
|
Chris@87
|
56 angle Returns angle of complex argument
|
Chris@87
|
57 unwrap Unwrap phase along given axis (1-d algorithm)
|
Chris@87
|
58 sort_complex Sort a complex-array (based on real, then imaginary)
|
Chris@87
|
59 trim_zeros Trim the leading and trailing zeros from 1D array.
|
Chris@87
|
60 vectorize A class that wraps a Python function taking scalar
|
Chris@87
|
61 arguments into a generalized function which can handle
|
Chris@87
|
62 arrays of arguments using the broadcast rules of
|
Chris@87
|
63 numerix Python.
|
Chris@87
|
64 ================ ===================
|
Chris@87
|
65
|
Chris@87
|
66 Shape Manipulation
|
Chris@87
|
67 ------------------
|
Chris@87
|
68 ================ ===================
|
Chris@87
|
69 squeeze Return a with length-one dimensions removed.
|
Chris@87
|
70 atleast_1d Force arrays to be > 1D
|
Chris@87
|
71 atleast_2d Force arrays to be > 2D
|
Chris@87
|
72 atleast_3d Force arrays to be > 3D
|
Chris@87
|
73 vstack Stack arrays vertically (row on row)
|
Chris@87
|
74 hstack Stack arrays horizontally (column on column)
|
Chris@87
|
75 column_stack Stack 1D arrays as columns into 2D array
|
Chris@87
|
76 dstack Stack arrays depthwise (along third dimension)
|
Chris@87
|
77 split Divide array into a list of sub-arrays
|
Chris@87
|
78 hsplit Split into columns
|
Chris@87
|
79 vsplit Split into rows
|
Chris@87
|
80 dsplit Split along third dimension
|
Chris@87
|
81 ================ ===================
|
Chris@87
|
82
|
Chris@87
|
83 Matrix (2D Array) Manipulations
|
Chris@87
|
84 -------------------------------
|
Chris@87
|
85 ================ ===================
|
Chris@87
|
86 fliplr 2D array with columns flipped
|
Chris@87
|
87 flipud 2D array with rows flipped
|
Chris@87
|
88 rot90 Rotate a 2D array a multiple of 90 degrees
|
Chris@87
|
89 eye Return a 2D array with ones down a given diagonal
|
Chris@87
|
90 diag Construct a 2D array from a vector, or return a given
|
Chris@87
|
91 diagonal from a 2D array.
|
Chris@87
|
92 mat Construct a Matrix
|
Chris@87
|
93 bmat Build a Matrix from blocks
|
Chris@87
|
94 ================ ===================
|
Chris@87
|
95
|
Chris@87
|
96 Polynomials
|
Chris@87
|
97 -----------
|
Chris@87
|
98 ================ ===================
|
Chris@87
|
99 poly1d A one-dimensional polynomial class
|
Chris@87
|
100 poly Return polynomial coefficients from roots
|
Chris@87
|
101 roots Find roots of polynomial given coefficients
|
Chris@87
|
102 polyint Integrate polynomial
|
Chris@87
|
103 polyder Differentiate polynomial
|
Chris@87
|
104 polyadd Add polynomials
|
Chris@87
|
105 polysub Substract polynomials
|
Chris@87
|
106 polymul Multiply polynomials
|
Chris@87
|
107 polydiv Divide polynomials
|
Chris@87
|
108 polyval Evaluate polynomial at given argument
|
Chris@87
|
109 ================ ===================
|
Chris@87
|
110
|
Chris@87
|
111 Import Tricks
|
Chris@87
|
112 -------------
|
Chris@87
|
113 ================ ===================
|
Chris@87
|
114 ppimport Postpone module import until trying to use it
|
Chris@87
|
115 ppimport_attr Postpone module import until trying to use its attribute
|
Chris@87
|
116 ppresolve Import postponed module and return it.
|
Chris@87
|
117 ================ ===================
|
Chris@87
|
118
|
Chris@87
|
119 Machine Arithmetics
|
Chris@87
|
120 -------------------
|
Chris@87
|
121 ================ ===================
|
Chris@87
|
122 machar_single Single precision floating point arithmetic parameters
|
Chris@87
|
123 machar_double Double precision floating point arithmetic parameters
|
Chris@87
|
124 ================ ===================
|
Chris@87
|
125
|
Chris@87
|
126 Threading Tricks
|
Chris@87
|
127 ----------------
|
Chris@87
|
128 ================ ===================
|
Chris@87
|
129 ParallelExec Execute commands in parallel thread.
|
Chris@87
|
130 ================ ===================
|
Chris@87
|
131
|
Chris@87
|
132 1D Array Set Operations
|
Chris@87
|
133 -----------------------
|
Chris@87
|
134 Set operations for 1D numeric arrays based on sort() function.
|
Chris@87
|
135
|
Chris@87
|
136 ================ ===================
|
Chris@87
|
137 ediff1d Array difference (auxiliary function).
|
Chris@87
|
138 unique Unique elements of an array.
|
Chris@87
|
139 intersect1d Intersection of 1D arrays with unique elements.
|
Chris@87
|
140 setxor1d Set exclusive-or of 1D arrays with unique elements.
|
Chris@87
|
141 in1d Test whether elements in a 1D array are also present in
|
Chris@87
|
142 another array.
|
Chris@87
|
143 union1d Union of 1D arrays with unique elements.
|
Chris@87
|
144 setdiff1d Set difference of 1D arrays with unique elements.
|
Chris@87
|
145 ================ ===================
|
Chris@87
|
146
|
Chris@87
|
147 """
|
Chris@87
|
148 from __future__ import division, absolute_import, print_function
|
Chris@87
|
149
|
Chris@87
|
150 depends = ['core', 'testing']
|
Chris@87
|
151 global_symbols = ['*']
|