Chris@87
|
1 """
|
Chris@87
|
2 This is only meant to add docs to objects defined in C-extension modules.
|
Chris@87
|
3 The purpose is to allow easier editing of the docstrings without
|
Chris@87
|
4 requiring a re-compile.
|
Chris@87
|
5
|
Chris@87
|
6 NOTE: Many of the methods of ndarray have corresponding functions.
|
Chris@87
|
7 If you update these docstrings, please keep also the ones in
|
Chris@87
|
8 core/fromnumeric.py, core/defmatrix.py up-to-date.
|
Chris@87
|
9
|
Chris@87
|
10 """
|
Chris@87
|
11 from __future__ import division, absolute_import, print_function
|
Chris@87
|
12
|
Chris@87
|
13 from numpy.lib import add_newdoc
|
Chris@87
|
14
|
Chris@87
|
15 ###############################################################################
|
Chris@87
|
16 #
|
Chris@87
|
17 # flatiter
|
Chris@87
|
18 #
|
Chris@87
|
19 # flatiter needs a toplevel description
|
Chris@87
|
20 #
|
Chris@87
|
21 ###############################################################################
|
Chris@87
|
22
|
Chris@87
|
23 add_newdoc('numpy.core', 'flatiter',
|
Chris@87
|
24 """
|
Chris@87
|
25 Flat iterator object to iterate over arrays.
|
Chris@87
|
26
|
Chris@87
|
27 A `flatiter` iterator is returned by ``x.flat`` for any array `x`.
|
Chris@87
|
28 It allows iterating over the array as if it were a 1-D array,
|
Chris@87
|
29 either in a for-loop or by calling its `next` method.
|
Chris@87
|
30
|
Chris@87
|
31 Iteration is done in C-contiguous style, with the last index varying the
|
Chris@87
|
32 fastest. The iterator can also be indexed using basic slicing or
|
Chris@87
|
33 advanced indexing.
|
Chris@87
|
34
|
Chris@87
|
35 See Also
|
Chris@87
|
36 --------
|
Chris@87
|
37 ndarray.flat : Return a flat iterator over an array.
|
Chris@87
|
38 ndarray.flatten : Returns a flattened copy of an array.
|
Chris@87
|
39
|
Chris@87
|
40 Notes
|
Chris@87
|
41 -----
|
Chris@87
|
42 A `flatiter` iterator can not be constructed directly from Python code
|
Chris@87
|
43 by calling the `flatiter` constructor.
|
Chris@87
|
44
|
Chris@87
|
45 Examples
|
Chris@87
|
46 --------
|
Chris@87
|
47 >>> x = np.arange(6).reshape(2, 3)
|
Chris@87
|
48 >>> fl = x.flat
|
Chris@87
|
49 >>> type(fl)
|
Chris@87
|
50 <type 'numpy.flatiter'>
|
Chris@87
|
51 >>> for item in fl:
|
Chris@87
|
52 ... print item
|
Chris@87
|
53 ...
|
Chris@87
|
54 0
|
Chris@87
|
55 1
|
Chris@87
|
56 2
|
Chris@87
|
57 3
|
Chris@87
|
58 4
|
Chris@87
|
59 5
|
Chris@87
|
60
|
Chris@87
|
61 >>> fl[2:4]
|
Chris@87
|
62 array([2, 3])
|
Chris@87
|
63
|
Chris@87
|
64 """)
|
Chris@87
|
65
|
Chris@87
|
66 # flatiter attributes
|
Chris@87
|
67
|
Chris@87
|
68 add_newdoc('numpy.core', 'flatiter', ('base',
|
Chris@87
|
69 """
|
Chris@87
|
70 A reference to the array that is iterated over.
|
Chris@87
|
71
|
Chris@87
|
72 Examples
|
Chris@87
|
73 --------
|
Chris@87
|
74 >>> x = np.arange(5)
|
Chris@87
|
75 >>> fl = x.flat
|
Chris@87
|
76 >>> fl.base is x
|
Chris@87
|
77 True
|
Chris@87
|
78
|
Chris@87
|
79 """))
|
Chris@87
|
80
|
Chris@87
|
81
|
Chris@87
|
82
|
Chris@87
|
83 add_newdoc('numpy.core', 'flatiter', ('coords',
|
Chris@87
|
84 """
|
Chris@87
|
85 An N-dimensional tuple of current coordinates.
|
Chris@87
|
86
|
Chris@87
|
87 Examples
|
Chris@87
|
88 --------
|
Chris@87
|
89 >>> x = np.arange(6).reshape(2, 3)
|
Chris@87
|
90 >>> fl = x.flat
|
Chris@87
|
91 >>> fl.coords
|
Chris@87
|
92 (0, 0)
|
Chris@87
|
93 >>> fl.next()
|
Chris@87
|
94 0
|
Chris@87
|
95 >>> fl.coords
|
Chris@87
|
96 (0, 1)
|
Chris@87
|
97
|
Chris@87
|
98 """))
|
Chris@87
|
99
|
Chris@87
|
100
|
Chris@87
|
101
|
Chris@87
|
102 add_newdoc('numpy.core', 'flatiter', ('index',
|
Chris@87
|
103 """
|
Chris@87
|
104 Current flat index into the array.
|
Chris@87
|
105
|
Chris@87
|
106 Examples
|
Chris@87
|
107 --------
|
Chris@87
|
108 >>> x = np.arange(6).reshape(2, 3)
|
Chris@87
|
109 >>> fl = x.flat
|
Chris@87
|
110 >>> fl.index
|
Chris@87
|
111 0
|
Chris@87
|
112 >>> fl.next()
|
Chris@87
|
113 0
|
Chris@87
|
114 >>> fl.index
|
Chris@87
|
115 1
|
Chris@87
|
116
|
Chris@87
|
117 """))
|
Chris@87
|
118
|
Chris@87
|
119 # flatiter functions
|
Chris@87
|
120
|
Chris@87
|
121 add_newdoc('numpy.core', 'flatiter', ('__array__',
|
Chris@87
|
122 """__array__(type=None) Get array from iterator
|
Chris@87
|
123
|
Chris@87
|
124 """))
|
Chris@87
|
125
|
Chris@87
|
126
|
Chris@87
|
127 add_newdoc('numpy.core', 'flatiter', ('copy',
|
Chris@87
|
128 """
|
Chris@87
|
129 copy()
|
Chris@87
|
130
|
Chris@87
|
131 Get a copy of the iterator as a 1-D array.
|
Chris@87
|
132
|
Chris@87
|
133 Examples
|
Chris@87
|
134 --------
|
Chris@87
|
135 >>> x = np.arange(6).reshape(2, 3)
|
Chris@87
|
136 >>> x
|
Chris@87
|
137 array([[0, 1, 2],
|
Chris@87
|
138 [3, 4, 5]])
|
Chris@87
|
139 >>> fl = x.flat
|
Chris@87
|
140 >>> fl.copy()
|
Chris@87
|
141 array([0, 1, 2, 3, 4, 5])
|
Chris@87
|
142
|
Chris@87
|
143 """))
|
Chris@87
|
144
|
Chris@87
|
145
|
Chris@87
|
146 ###############################################################################
|
Chris@87
|
147 #
|
Chris@87
|
148 # nditer
|
Chris@87
|
149 #
|
Chris@87
|
150 ###############################################################################
|
Chris@87
|
151
|
Chris@87
|
152 add_newdoc('numpy.core', 'nditer',
|
Chris@87
|
153 """
|
Chris@87
|
154 Efficient multi-dimensional iterator object to iterate over arrays.
|
Chris@87
|
155 To get started using this object, see the
|
Chris@87
|
156 :ref:`introductory guide to array iteration <arrays.nditer>`.
|
Chris@87
|
157
|
Chris@87
|
158 Parameters
|
Chris@87
|
159 ----------
|
Chris@87
|
160 op : ndarray or sequence of array_like
|
Chris@87
|
161 The array(s) to iterate over.
|
Chris@87
|
162 flags : sequence of str, optional
|
Chris@87
|
163 Flags to control the behavior of the iterator.
|
Chris@87
|
164
|
Chris@87
|
165 * "buffered" enables buffering when required.
|
Chris@87
|
166 * "c_index" causes a C-order index to be tracked.
|
Chris@87
|
167 * "f_index" causes a Fortran-order index to be tracked.
|
Chris@87
|
168 * "multi_index" causes a multi-index, or a tuple of indices
|
Chris@87
|
169 with one per iteration dimension, to be tracked.
|
Chris@87
|
170 * "common_dtype" causes all the operands to be converted to
|
Chris@87
|
171 a common data type, with copying or buffering as necessary.
|
Chris@87
|
172 * "delay_bufalloc" delays allocation of the buffers until
|
Chris@87
|
173 a reset() call is made. Allows "allocate" operands to
|
Chris@87
|
174 be initialized before their values are copied into the buffers.
|
Chris@87
|
175 * "external_loop" causes the `values` given to be
|
Chris@87
|
176 one-dimensional arrays with multiple values instead of
|
Chris@87
|
177 zero-dimensional arrays.
|
Chris@87
|
178 * "grow_inner" allows the `value` array sizes to be made
|
Chris@87
|
179 larger than the buffer size when both "buffered" and
|
Chris@87
|
180 "external_loop" is used.
|
Chris@87
|
181 * "ranged" allows the iterator to be restricted to a sub-range
|
Chris@87
|
182 of the iterindex values.
|
Chris@87
|
183 * "refs_ok" enables iteration of reference types, such as
|
Chris@87
|
184 object arrays.
|
Chris@87
|
185 * "reduce_ok" enables iteration of "readwrite" operands
|
Chris@87
|
186 which are broadcasted, also known as reduction operands.
|
Chris@87
|
187 * "zerosize_ok" allows `itersize` to be zero.
|
Chris@87
|
188 op_flags : list of list of str, optional
|
Chris@87
|
189 This is a list of flags for each operand. At minimum, one of
|
Chris@87
|
190 "readonly", "readwrite", or "writeonly" must be specified.
|
Chris@87
|
191
|
Chris@87
|
192 * "readonly" indicates the operand will only be read from.
|
Chris@87
|
193 * "readwrite" indicates the operand will be read from and written to.
|
Chris@87
|
194 * "writeonly" indicates the operand will only be written to.
|
Chris@87
|
195 * "no_broadcast" prevents the operand from being broadcasted.
|
Chris@87
|
196 * "contig" forces the operand data to be contiguous.
|
Chris@87
|
197 * "aligned" forces the operand data to be aligned.
|
Chris@87
|
198 * "nbo" forces the operand data to be in native byte order.
|
Chris@87
|
199 * "copy" allows a temporary read-only copy if required.
|
Chris@87
|
200 * "updateifcopy" allows a temporary read-write copy if required.
|
Chris@87
|
201 * "allocate" causes the array to be allocated if it is None
|
Chris@87
|
202 in the `op` parameter.
|
Chris@87
|
203 * "no_subtype" prevents an "allocate" operand from using a subtype.
|
Chris@87
|
204 * "arraymask" indicates that this operand is the mask to use
|
Chris@87
|
205 for selecting elements when writing to operands with the
|
Chris@87
|
206 'writemasked' flag set. The iterator does not enforce this,
|
Chris@87
|
207 but when writing from a buffer back to the array, it only
|
Chris@87
|
208 copies those elements indicated by this mask.
|
Chris@87
|
209 * 'writemasked' indicates that only elements where the chosen
|
Chris@87
|
210 'arraymask' operand is True will be written to.
|
Chris@87
|
211 op_dtypes : dtype or tuple of dtype(s), optional
|
Chris@87
|
212 The required data type(s) of the operands. If copying or buffering
|
Chris@87
|
213 is enabled, the data will be converted to/from their original types.
|
Chris@87
|
214 order : {'C', 'F', 'A', 'K'}, optional
|
Chris@87
|
215 Controls the iteration order. 'C' means C order, 'F' means
|
Chris@87
|
216 Fortran order, 'A' means 'F' order if all the arrays are Fortran
|
Chris@87
|
217 contiguous, 'C' order otherwise, and 'K' means as close to the
|
Chris@87
|
218 order the array elements appear in memory as possible. This also
|
Chris@87
|
219 affects the element memory order of "allocate" operands, as they
|
Chris@87
|
220 are allocated to be compatible with iteration order.
|
Chris@87
|
221 Default is 'K'.
|
Chris@87
|
222 casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
|
Chris@87
|
223 Controls what kind of data casting may occur when making a copy
|
Chris@87
|
224 or buffering. Setting this to 'unsafe' is not recommended,
|
Chris@87
|
225 as it can adversely affect accumulations.
|
Chris@87
|
226
|
Chris@87
|
227 * 'no' means the data types should not be cast at all.
|
Chris@87
|
228 * 'equiv' means only byte-order changes are allowed.
|
Chris@87
|
229 * 'safe' means only casts which can preserve values are allowed.
|
Chris@87
|
230 * 'same_kind' means only safe casts or casts within a kind,
|
Chris@87
|
231 like float64 to float32, are allowed.
|
Chris@87
|
232 * 'unsafe' means any data conversions may be done.
|
Chris@87
|
233 op_axes : list of list of ints, optional
|
Chris@87
|
234 If provided, is a list of ints or None for each operands.
|
Chris@87
|
235 The list of axes for an operand is a mapping from the dimensions
|
Chris@87
|
236 of the iterator to the dimensions of the operand. A value of
|
Chris@87
|
237 -1 can be placed for entries, causing that dimension to be
|
Chris@87
|
238 treated as "newaxis".
|
Chris@87
|
239 itershape : tuple of ints, optional
|
Chris@87
|
240 The desired shape of the iterator. This allows "allocate" operands
|
Chris@87
|
241 with a dimension mapped by op_axes not corresponding to a dimension
|
Chris@87
|
242 of a different operand to get a value not equal to 1 for that
|
Chris@87
|
243 dimension.
|
Chris@87
|
244 buffersize : int, optional
|
Chris@87
|
245 When buffering is enabled, controls the size of the temporary
|
Chris@87
|
246 buffers. Set to 0 for the default value.
|
Chris@87
|
247
|
Chris@87
|
248 Attributes
|
Chris@87
|
249 ----------
|
Chris@87
|
250 dtypes : tuple of dtype(s)
|
Chris@87
|
251 The data types of the values provided in `value`. This may be
|
Chris@87
|
252 different from the operand data types if buffering is enabled.
|
Chris@87
|
253 finished : bool
|
Chris@87
|
254 Whether the iteration over the operands is finished or not.
|
Chris@87
|
255 has_delayed_bufalloc : bool
|
Chris@87
|
256 If True, the iterator was created with the "delay_bufalloc" flag,
|
Chris@87
|
257 and no reset() function was called on it yet.
|
Chris@87
|
258 has_index : bool
|
Chris@87
|
259 If True, the iterator was created with either the "c_index" or
|
Chris@87
|
260 the "f_index" flag, and the property `index` can be used to
|
Chris@87
|
261 retrieve it.
|
Chris@87
|
262 has_multi_index : bool
|
Chris@87
|
263 If True, the iterator was created with the "multi_index" flag,
|
Chris@87
|
264 and the property `multi_index` can be used to retrieve it.
|
Chris@87
|
265 index :
|
Chris@87
|
266 When the "c_index" or "f_index" flag was used, this property
|
Chris@87
|
267 provides access to the index. Raises a ValueError if accessed
|
Chris@87
|
268 and `has_index` is False.
|
Chris@87
|
269 iterationneedsapi : bool
|
Chris@87
|
270 Whether iteration requires access to the Python API, for example
|
Chris@87
|
271 if one of the operands is an object array.
|
Chris@87
|
272 iterindex : int
|
Chris@87
|
273 An index which matches the order of iteration.
|
Chris@87
|
274 itersize : int
|
Chris@87
|
275 Size of the iterator.
|
Chris@87
|
276 itviews :
|
Chris@87
|
277 Structured view(s) of `operands` in memory, matching the reordered
|
Chris@87
|
278 and optimized iterator access pattern.
|
Chris@87
|
279 multi_index :
|
Chris@87
|
280 When the "multi_index" flag was used, this property
|
Chris@87
|
281 provides access to the index. Raises a ValueError if accessed
|
Chris@87
|
282 accessed and `has_multi_index` is False.
|
Chris@87
|
283 ndim : int
|
Chris@87
|
284 The iterator's dimension.
|
Chris@87
|
285 nop : int
|
Chris@87
|
286 The number of iterator operands.
|
Chris@87
|
287 operands : tuple of operand(s)
|
Chris@87
|
288 The array(s) to be iterated over.
|
Chris@87
|
289 shape : tuple of ints
|
Chris@87
|
290 Shape tuple, the shape of the iterator.
|
Chris@87
|
291 value :
|
Chris@87
|
292 Value of `operands` at current iteration. Normally, this is a
|
Chris@87
|
293 tuple of array scalars, but if the flag "external_loop" is used,
|
Chris@87
|
294 it is a tuple of one dimensional arrays.
|
Chris@87
|
295
|
Chris@87
|
296 Notes
|
Chris@87
|
297 -----
|
Chris@87
|
298 `nditer` supersedes `flatiter`. The iterator implementation behind
|
Chris@87
|
299 `nditer` is also exposed by the Numpy C API.
|
Chris@87
|
300
|
Chris@87
|
301 The Python exposure supplies two iteration interfaces, one which follows
|
Chris@87
|
302 the Python iterator protocol, and another which mirrors the C-style
|
Chris@87
|
303 do-while pattern. The native Python approach is better in most cases, but
|
Chris@87
|
304 if you need the iterator's coordinates or index, use the C-style pattern.
|
Chris@87
|
305
|
Chris@87
|
306 Examples
|
Chris@87
|
307 --------
|
Chris@87
|
308 Here is how we might write an ``iter_add`` function, using the
|
Chris@87
|
309 Python iterator protocol::
|
Chris@87
|
310
|
Chris@87
|
311 def iter_add_py(x, y, out=None):
|
Chris@87
|
312 addop = np.add
|
Chris@87
|
313 it = np.nditer([x, y, out], [],
|
Chris@87
|
314 [['readonly'], ['readonly'], ['writeonly','allocate']])
|
Chris@87
|
315 for (a, b, c) in it:
|
Chris@87
|
316 addop(a, b, out=c)
|
Chris@87
|
317 return it.operands[2]
|
Chris@87
|
318
|
Chris@87
|
319 Here is the same function, but following the C-style pattern::
|
Chris@87
|
320
|
Chris@87
|
321 def iter_add(x, y, out=None):
|
Chris@87
|
322 addop = np.add
|
Chris@87
|
323
|
Chris@87
|
324 it = np.nditer([x, y, out], [],
|
Chris@87
|
325 [['readonly'], ['readonly'], ['writeonly','allocate']])
|
Chris@87
|
326
|
Chris@87
|
327 while not it.finished:
|
Chris@87
|
328 addop(it[0], it[1], out=it[2])
|
Chris@87
|
329 it.iternext()
|
Chris@87
|
330
|
Chris@87
|
331 return it.operands[2]
|
Chris@87
|
332
|
Chris@87
|
333 Here is an example outer product function::
|
Chris@87
|
334
|
Chris@87
|
335 def outer_it(x, y, out=None):
|
Chris@87
|
336 mulop = np.multiply
|
Chris@87
|
337
|
Chris@87
|
338 it = np.nditer([x, y, out], ['external_loop'],
|
Chris@87
|
339 [['readonly'], ['readonly'], ['writeonly', 'allocate']],
|
Chris@87
|
340 op_axes=[range(x.ndim)+[-1]*y.ndim,
|
Chris@87
|
341 [-1]*x.ndim+range(y.ndim),
|
Chris@87
|
342 None])
|
Chris@87
|
343
|
Chris@87
|
344 for (a, b, c) in it:
|
Chris@87
|
345 mulop(a, b, out=c)
|
Chris@87
|
346
|
Chris@87
|
347 return it.operands[2]
|
Chris@87
|
348
|
Chris@87
|
349 >>> a = np.arange(2)+1
|
Chris@87
|
350 >>> b = np.arange(3)+1
|
Chris@87
|
351 >>> outer_it(a,b)
|
Chris@87
|
352 array([[1, 2, 3],
|
Chris@87
|
353 [2, 4, 6]])
|
Chris@87
|
354
|
Chris@87
|
355 Here is an example function which operates like a "lambda" ufunc::
|
Chris@87
|
356
|
Chris@87
|
357 def luf(lamdaexpr, *args, **kwargs):
|
Chris@87
|
358 "luf(lambdaexpr, op1, ..., opn, out=None, order='K', casting='safe', buffersize=0)"
|
Chris@87
|
359 nargs = len(args)
|
Chris@87
|
360 op = (kwargs.get('out',None),) + args
|
Chris@87
|
361 it = np.nditer(op, ['buffered','external_loop'],
|
Chris@87
|
362 [['writeonly','allocate','no_broadcast']] +
|
Chris@87
|
363 [['readonly','nbo','aligned']]*nargs,
|
Chris@87
|
364 order=kwargs.get('order','K'),
|
Chris@87
|
365 casting=kwargs.get('casting','safe'),
|
Chris@87
|
366 buffersize=kwargs.get('buffersize',0))
|
Chris@87
|
367 while not it.finished:
|
Chris@87
|
368 it[0] = lamdaexpr(*it[1:])
|
Chris@87
|
369 it.iternext()
|
Chris@87
|
370 return it.operands[0]
|
Chris@87
|
371
|
Chris@87
|
372 >>> a = np.arange(5)
|
Chris@87
|
373 >>> b = np.ones(5)
|
Chris@87
|
374 >>> luf(lambda i,j:i*i + j/2, a, b)
|
Chris@87
|
375 array([ 0.5, 1.5, 4.5, 9.5, 16.5])
|
Chris@87
|
376
|
Chris@87
|
377 """)
|
Chris@87
|
378
|
Chris@87
|
379 # nditer methods
|
Chris@87
|
380
|
Chris@87
|
381 add_newdoc('numpy.core', 'nditer', ('copy',
|
Chris@87
|
382 """
|
Chris@87
|
383 copy()
|
Chris@87
|
384
|
Chris@87
|
385 Get a copy of the iterator in its current state.
|
Chris@87
|
386
|
Chris@87
|
387 Examples
|
Chris@87
|
388 --------
|
Chris@87
|
389 >>> x = np.arange(10)
|
Chris@87
|
390 >>> y = x + 1
|
Chris@87
|
391 >>> it = np.nditer([x, y])
|
Chris@87
|
392 >>> it.next()
|
Chris@87
|
393 (array(0), array(1))
|
Chris@87
|
394 >>> it2 = it.copy()
|
Chris@87
|
395 >>> it2.next()
|
Chris@87
|
396 (array(1), array(2))
|
Chris@87
|
397
|
Chris@87
|
398 """))
|
Chris@87
|
399
|
Chris@87
|
400 add_newdoc('numpy.core', 'nditer', ('debug_print',
|
Chris@87
|
401 """
|
Chris@87
|
402 debug_print()
|
Chris@87
|
403
|
Chris@87
|
404 Print the current state of the `nditer` instance and debug info to stdout.
|
Chris@87
|
405
|
Chris@87
|
406 """))
|
Chris@87
|
407
|
Chris@87
|
408 add_newdoc('numpy.core', 'nditer', ('enable_external_loop',
|
Chris@87
|
409 """
|
Chris@87
|
410 enable_external_loop()
|
Chris@87
|
411
|
Chris@87
|
412 When the "external_loop" was not used during construction, but
|
Chris@87
|
413 is desired, this modifies the iterator to behave as if the flag
|
Chris@87
|
414 was specified.
|
Chris@87
|
415
|
Chris@87
|
416 """))
|
Chris@87
|
417
|
Chris@87
|
418 add_newdoc('numpy.core', 'nditer', ('iternext',
|
Chris@87
|
419 """
|
Chris@87
|
420 iternext()
|
Chris@87
|
421
|
Chris@87
|
422 Check whether iterations are left, and perform a single internal iteration
|
Chris@87
|
423 without returning the result. Used in the C-style pattern do-while
|
Chris@87
|
424 pattern. For an example, see `nditer`.
|
Chris@87
|
425
|
Chris@87
|
426 Returns
|
Chris@87
|
427 -------
|
Chris@87
|
428 iternext : bool
|
Chris@87
|
429 Whether or not there are iterations left.
|
Chris@87
|
430
|
Chris@87
|
431 """))
|
Chris@87
|
432
|
Chris@87
|
433 add_newdoc('numpy.core', 'nditer', ('remove_axis',
|
Chris@87
|
434 """
|
Chris@87
|
435 remove_axis(i)
|
Chris@87
|
436
|
Chris@87
|
437 Removes axis `i` from the iterator. Requires that the flag "multi_index"
|
Chris@87
|
438 be enabled.
|
Chris@87
|
439
|
Chris@87
|
440 """))
|
Chris@87
|
441
|
Chris@87
|
442 add_newdoc('numpy.core', 'nditer', ('remove_multi_index',
|
Chris@87
|
443 """
|
Chris@87
|
444 remove_multi_index()
|
Chris@87
|
445
|
Chris@87
|
446 When the "multi_index" flag was specified, this removes it, allowing
|
Chris@87
|
447 the internal iteration structure to be optimized further.
|
Chris@87
|
448
|
Chris@87
|
449 """))
|
Chris@87
|
450
|
Chris@87
|
451 add_newdoc('numpy.core', 'nditer', ('reset',
|
Chris@87
|
452 """
|
Chris@87
|
453 reset()
|
Chris@87
|
454
|
Chris@87
|
455 Reset the iterator to its initial state.
|
Chris@87
|
456
|
Chris@87
|
457 """))
|
Chris@87
|
458
|
Chris@87
|
459
|
Chris@87
|
460
|
Chris@87
|
461 ###############################################################################
|
Chris@87
|
462 #
|
Chris@87
|
463 # broadcast
|
Chris@87
|
464 #
|
Chris@87
|
465 ###############################################################################
|
Chris@87
|
466
|
Chris@87
|
467 add_newdoc('numpy.core', 'broadcast',
|
Chris@87
|
468 """
|
Chris@87
|
469 Produce an object that mimics broadcasting.
|
Chris@87
|
470
|
Chris@87
|
471 Parameters
|
Chris@87
|
472 ----------
|
Chris@87
|
473 in1, in2, ... : array_like
|
Chris@87
|
474 Input parameters.
|
Chris@87
|
475
|
Chris@87
|
476 Returns
|
Chris@87
|
477 -------
|
Chris@87
|
478 b : broadcast object
|
Chris@87
|
479 Broadcast the input parameters against one another, and
|
Chris@87
|
480 return an object that encapsulates the result.
|
Chris@87
|
481 Amongst others, it has ``shape`` and ``nd`` properties, and
|
Chris@87
|
482 may be used as an iterator.
|
Chris@87
|
483
|
Chris@87
|
484 Examples
|
Chris@87
|
485 --------
|
Chris@87
|
486 Manually adding two vectors, using broadcasting:
|
Chris@87
|
487
|
Chris@87
|
488 >>> x = np.array([[1], [2], [3]])
|
Chris@87
|
489 >>> y = np.array([4, 5, 6])
|
Chris@87
|
490 >>> b = np.broadcast(x, y)
|
Chris@87
|
491
|
Chris@87
|
492 >>> out = np.empty(b.shape)
|
Chris@87
|
493 >>> out.flat = [u+v for (u,v) in b]
|
Chris@87
|
494 >>> out
|
Chris@87
|
495 array([[ 5., 6., 7.],
|
Chris@87
|
496 [ 6., 7., 8.],
|
Chris@87
|
497 [ 7., 8., 9.]])
|
Chris@87
|
498
|
Chris@87
|
499 Compare against built-in broadcasting:
|
Chris@87
|
500
|
Chris@87
|
501 >>> x + y
|
Chris@87
|
502 array([[5, 6, 7],
|
Chris@87
|
503 [6, 7, 8],
|
Chris@87
|
504 [7, 8, 9]])
|
Chris@87
|
505
|
Chris@87
|
506 """)
|
Chris@87
|
507
|
Chris@87
|
508 # attributes
|
Chris@87
|
509
|
Chris@87
|
510 add_newdoc('numpy.core', 'broadcast', ('index',
|
Chris@87
|
511 """
|
Chris@87
|
512 current index in broadcasted result
|
Chris@87
|
513
|
Chris@87
|
514 Examples
|
Chris@87
|
515 --------
|
Chris@87
|
516 >>> x = np.array([[1], [2], [3]])
|
Chris@87
|
517 >>> y = np.array([4, 5, 6])
|
Chris@87
|
518 >>> b = np.broadcast(x, y)
|
Chris@87
|
519 >>> b.index
|
Chris@87
|
520 0
|
Chris@87
|
521 >>> b.next(), b.next(), b.next()
|
Chris@87
|
522 ((1, 4), (1, 5), (1, 6))
|
Chris@87
|
523 >>> b.index
|
Chris@87
|
524 3
|
Chris@87
|
525
|
Chris@87
|
526 """))
|
Chris@87
|
527
|
Chris@87
|
528 add_newdoc('numpy.core', 'broadcast', ('iters',
|
Chris@87
|
529 """
|
Chris@87
|
530 tuple of iterators along ``self``'s "components."
|
Chris@87
|
531
|
Chris@87
|
532 Returns a tuple of `numpy.flatiter` objects, one for each "component"
|
Chris@87
|
533 of ``self``.
|
Chris@87
|
534
|
Chris@87
|
535 See Also
|
Chris@87
|
536 --------
|
Chris@87
|
537 numpy.flatiter
|
Chris@87
|
538
|
Chris@87
|
539 Examples
|
Chris@87
|
540 --------
|
Chris@87
|
541 >>> x = np.array([1, 2, 3])
|
Chris@87
|
542 >>> y = np.array([[4], [5], [6]])
|
Chris@87
|
543 >>> b = np.broadcast(x, y)
|
Chris@87
|
544 >>> row, col = b.iters
|
Chris@87
|
545 >>> row.next(), col.next()
|
Chris@87
|
546 (1, 4)
|
Chris@87
|
547
|
Chris@87
|
548 """))
|
Chris@87
|
549
|
Chris@87
|
550 add_newdoc('numpy.core', 'broadcast', ('nd',
|
Chris@87
|
551 """
|
Chris@87
|
552 Number of dimensions of broadcasted result.
|
Chris@87
|
553
|
Chris@87
|
554 Examples
|
Chris@87
|
555 --------
|
Chris@87
|
556 >>> x = np.array([1, 2, 3])
|
Chris@87
|
557 >>> y = np.array([[4], [5], [6]])
|
Chris@87
|
558 >>> b = np.broadcast(x, y)
|
Chris@87
|
559 >>> b.nd
|
Chris@87
|
560 2
|
Chris@87
|
561
|
Chris@87
|
562 """))
|
Chris@87
|
563
|
Chris@87
|
564 add_newdoc('numpy.core', 'broadcast', ('numiter',
|
Chris@87
|
565 """
|
Chris@87
|
566 Number of iterators possessed by the broadcasted result.
|
Chris@87
|
567
|
Chris@87
|
568 Examples
|
Chris@87
|
569 --------
|
Chris@87
|
570 >>> x = np.array([1, 2, 3])
|
Chris@87
|
571 >>> y = np.array([[4], [5], [6]])
|
Chris@87
|
572 >>> b = np.broadcast(x, y)
|
Chris@87
|
573 >>> b.numiter
|
Chris@87
|
574 2
|
Chris@87
|
575
|
Chris@87
|
576 """))
|
Chris@87
|
577
|
Chris@87
|
578 add_newdoc('numpy.core', 'broadcast', ('shape',
|
Chris@87
|
579 """
|
Chris@87
|
580 Shape of broadcasted result.
|
Chris@87
|
581
|
Chris@87
|
582 Examples
|
Chris@87
|
583 --------
|
Chris@87
|
584 >>> x = np.array([1, 2, 3])
|
Chris@87
|
585 >>> y = np.array([[4], [5], [6]])
|
Chris@87
|
586 >>> b = np.broadcast(x, y)
|
Chris@87
|
587 >>> b.shape
|
Chris@87
|
588 (3, 3)
|
Chris@87
|
589
|
Chris@87
|
590 """))
|
Chris@87
|
591
|
Chris@87
|
592 add_newdoc('numpy.core', 'broadcast', ('size',
|
Chris@87
|
593 """
|
Chris@87
|
594 Total size of broadcasted result.
|
Chris@87
|
595
|
Chris@87
|
596 Examples
|
Chris@87
|
597 --------
|
Chris@87
|
598 >>> x = np.array([1, 2, 3])
|
Chris@87
|
599 >>> y = np.array([[4], [5], [6]])
|
Chris@87
|
600 >>> b = np.broadcast(x, y)
|
Chris@87
|
601 >>> b.size
|
Chris@87
|
602 9
|
Chris@87
|
603
|
Chris@87
|
604 """))
|
Chris@87
|
605
|
Chris@87
|
606 add_newdoc('numpy.core', 'broadcast', ('reset',
|
Chris@87
|
607 """
|
Chris@87
|
608 reset()
|
Chris@87
|
609
|
Chris@87
|
610 Reset the broadcasted result's iterator(s).
|
Chris@87
|
611
|
Chris@87
|
612 Parameters
|
Chris@87
|
613 ----------
|
Chris@87
|
614 None
|
Chris@87
|
615
|
Chris@87
|
616 Returns
|
Chris@87
|
617 -------
|
Chris@87
|
618 None
|
Chris@87
|
619
|
Chris@87
|
620 Examples
|
Chris@87
|
621 --------
|
Chris@87
|
622 >>> x = np.array([1, 2, 3])
|
Chris@87
|
623 >>> y = np.array([[4], [5], [6]]
|
Chris@87
|
624 >>> b = np.broadcast(x, y)
|
Chris@87
|
625 >>> b.index
|
Chris@87
|
626 0
|
Chris@87
|
627 >>> b.next(), b.next(), b.next()
|
Chris@87
|
628 ((1, 4), (2, 4), (3, 4))
|
Chris@87
|
629 >>> b.index
|
Chris@87
|
630 3
|
Chris@87
|
631 >>> b.reset()
|
Chris@87
|
632 >>> b.index
|
Chris@87
|
633 0
|
Chris@87
|
634
|
Chris@87
|
635 """))
|
Chris@87
|
636
|
Chris@87
|
637 ###############################################################################
|
Chris@87
|
638 #
|
Chris@87
|
639 # numpy functions
|
Chris@87
|
640 #
|
Chris@87
|
641 ###############################################################################
|
Chris@87
|
642
|
Chris@87
|
643 add_newdoc('numpy.core.multiarray', 'array',
|
Chris@87
|
644 """
|
Chris@87
|
645 array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
|
Chris@87
|
646
|
Chris@87
|
647 Create an array.
|
Chris@87
|
648
|
Chris@87
|
649 Parameters
|
Chris@87
|
650 ----------
|
Chris@87
|
651 object : array_like
|
Chris@87
|
652 An array, any object exposing the array interface, an
|
Chris@87
|
653 object whose __array__ method returns an array, or any
|
Chris@87
|
654 (nested) sequence.
|
Chris@87
|
655 dtype : data-type, optional
|
Chris@87
|
656 The desired data-type for the array. If not given, then
|
Chris@87
|
657 the type will be determined as the minimum type required
|
Chris@87
|
658 to hold the objects in the sequence. This argument can only
|
Chris@87
|
659 be used to 'upcast' the array. For downcasting, use the
|
Chris@87
|
660 .astype(t) method.
|
Chris@87
|
661 copy : bool, optional
|
Chris@87
|
662 If true (default), then the object is copied. Otherwise, a copy
|
Chris@87
|
663 will only be made if __array__ returns a copy, if obj is a
|
Chris@87
|
664 nested sequence, or if a copy is needed to satisfy any of the other
|
Chris@87
|
665 requirements (`dtype`, `order`, etc.).
|
Chris@87
|
666 order : {'C', 'F', 'A'}, optional
|
Chris@87
|
667 Specify the order of the array. If order is 'C' (default), then the
|
Chris@87
|
668 array will be in C-contiguous order (last-index varies the
|
Chris@87
|
669 fastest). If order is 'F', then the returned array
|
Chris@87
|
670 will be in Fortran-contiguous order (first-index varies the
|
Chris@87
|
671 fastest). If order is 'A', then the returned array may
|
Chris@87
|
672 be in any order (either C-, Fortran-contiguous, or even
|
Chris@87
|
673 discontiguous).
|
Chris@87
|
674 subok : bool, optional
|
Chris@87
|
675 If True, then sub-classes will be passed-through, otherwise
|
Chris@87
|
676 the returned array will be forced to be a base-class array (default).
|
Chris@87
|
677 ndmin : int, optional
|
Chris@87
|
678 Specifies the minimum number of dimensions that the resulting
|
Chris@87
|
679 array should have. Ones will be pre-pended to the shape as
|
Chris@87
|
680 needed to meet this requirement.
|
Chris@87
|
681
|
Chris@87
|
682 Returns
|
Chris@87
|
683 -------
|
Chris@87
|
684 out : ndarray
|
Chris@87
|
685 An array object satisfying the specified requirements.
|
Chris@87
|
686
|
Chris@87
|
687 See Also
|
Chris@87
|
688 --------
|
Chris@87
|
689 empty, empty_like, zeros, zeros_like, ones, ones_like, fill
|
Chris@87
|
690
|
Chris@87
|
691 Examples
|
Chris@87
|
692 --------
|
Chris@87
|
693 >>> np.array([1, 2, 3])
|
Chris@87
|
694 array([1, 2, 3])
|
Chris@87
|
695
|
Chris@87
|
696 Upcasting:
|
Chris@87
|
697
|
Chris@87
|
698 >>> np.array([1, 2, 3.0])
|
Chris@87
|
699 array([ 1., 2., 3.])
|
Chris@87
|
700
|
Chris@87
|
701 More than one dimension:
|
Chris@87
|
702
|
Chris@87
|
703 >>> np.array([[1, 2], [3, 4]])
|
Chris@87
|
704 array([[1, 2],
|
Chris@87
|
705 [3, 4]])
|
Chris@87
|
706
|
Chris@87
|
707 Minimum dimensions 2:
|
Chris@87
|
708
|
Chris@87
|
709 >>> np.array([1, 2, 3], ndmin=2)
|
Chris@87
|
710 array([[1, 2, 3]])
|
Chris@87
|
711
|
Chris@87
|
712 Type provided:
|
Chris@87
|
713
|
Chris@87
|
714 >>> np.array([1, 2, 3], dtype=complex)
|
Chris@87
|
715 array([ 1.+0.j, 2.+0.j, 3.+0.j])
|
Chris@87
|
716
|
Chris@87
|
717 Data-type consisting of more than one element:
|
Chris@87
|
718
|
Chris@87
|
719 >>> x = np.array([(1,2),(3,4)],dtype=[('a','<i4'),('b','<i4')])
|
Chris@87
|
720 >>> x['a']
|
Chris@87
|
721 array([1, 3])
|
Chris@87
|
722
|
Chris@87
|
723 Creating an array from sub-classes:
|
Chris@87
|
724
|
Chris@87
|
725 >>> np.array(np.mat('1 2; 3 4'))
|
Chris@87
|
726 array([[1, 2],
|
Chris@87
|
727 [3, 4]])
|
Chris@87
|
728
|
Chris@87
|
729 >>> np.array(np.mat('1 2; 3 4'), subok=True)
|
Chris@87
|
730 matrix([[1, 2],
|
Chris@87
|
731 [3, 4]])
|
Chris@87
|
732
|
Chris@87
|
733 """)
|
Chris@87
|
734
|
Chris@87
|
735 add_newdoc('numpy.core.multiarray', 'empty',
|
Chris@87
|
736 """
|
Chris@87
|
737 empty(shape, dtype=float, order='C')
|
Chris@87
|
738
|
Chris@87
|
739 Return a new array of given shape and type, without initializing entries.
|
Chris@87
|
740
|
Chris@87
|
741 Parameters
|
Chris@87
|
742 ----------
|
Chris@87
|
743 shape : int or tuple of int
|
Chris@87
|
744 Shape of the empty array
|
Chris@87
|
745 dtype : data-type, optional
|
Chris@87
|
746 Desired output data-type.
|
Chris@87
|
747 order : {'C', 'F'}, optional
|
Chris@87
|
748 Whether to store multi-dimensional data in C (row-major) or
|
Chris@87
|
749 Fortran (column-major) order in memory.
|
Chris@87
|
750
|
Chris@87
|
751 Returns
|
Chris@87
|
752 -------
|
Chris@87
|
753 out : ndarray
|
Chris@87
|
754 Array of uninitialized (arbitrary) data with the given
|
Chris@87
|
755 shape, dtype, and order.
|
Chris@87
|
756
|
Chris@87
|
757 See Also
|
Chris@87
|
758 --------
|
Chris@87
|
759 empty_like, zeros, ones
|
Chris@87
|
760
|
Chris@87
|
761 Notes
|
Chris@87
|
762 -----
|
Chris@87
|
763 `empty`, unlike `zeros`, does not set the array values to zero,
|
Chris@87
|
764 and may therefore be marginally faster. On the other hand, it requires
|
Chris@87
|
765 the user to manually set all the values in the array, and should be
|
Chris@87
|
766 used with caution.
|
Chris@87
|
767
|
Chris@87
|
768 Examples
|
Chris@87
|
769 --------
|
Chris@87
|
770 >>> np.empty([2, 2])
|
Chris@87
|
771 array([[ -9.74499359e+001, 6.69583040e-309],
|
Chris@87
|
772 [ 2.13182611e-314, 3.06959433e-309]]) #random
|
Chris@87
|
773
|
Chris@87
|
774 >>> np.empty([2, 2], dtype=int)
|
Chris@87
|
775 array([[-1073741821, -1067949133],
|
Chris@87
|
776 [ 496041986, 19249760]]) #random
|
Chris@87
|
777
|
Chris@87
|
778 """)
|
Chris@87
|
779
|
Chris@87
|
780 add_newdoc('numpy.core.multiarray', 'empty_like',
|
Chris@87
|
781 """
|
Chris@87
|
782 empty_like(a, dtype=None, order='K', subok=True)
|
Chris@87
|
783
|
Chris@87
|
784 Return a new array with the same shape and type as a given array.
|
Chris@87
|
785
|
Chris@87
|
786 Parameters
|
Chris@87
|
787 ----------
|
Chris@87
|
788 a : array_like
|
Chris@87
|
789 The shape and data-type of `a` define these same attributes of the
|
Chris@87
|
790 returned array.
|
Chris@87
|
791 dtype : data-type, optional
|
Chris@87
|
792 .. versionadded:: 1.6.0
|
Chris@87
|
793 Overrides the data type of the result.
|
Chris@87
|
794 order : {'C', 'F', 'A', or 'K'}, optional
|
Chris@87
|
795 .. versionadded:: 1.6.0
|
Chris@87
|
796 Overrides the memory layout of the result. 'C' means C-order,
|
Chris@87
|
797 'F' means F-order, 'A' means 'F' if ``a`` is Fortran contiguous,
|
Chris@87
|
798 'C' otherwise. 'K' means match the layout of ``a`` as closely
|
Chris@87
|
799 as possible.
|
Chris@87
|
800 subok : bool, optional.
|
Chris@87
|
801 If True, then the newly created array will use the sub-class
|
Chris@87
|
802 type of 'a', otherwise it will be a base-class array. Defaults
|
Chris@87
|
803 to True.
|
Chris@87
|
804
|
Chris@87
|
805 Returns
|
Chris@87
|
806 -------
|
Chris@87
|
807 out : ndarray
|
Chris@87
|
808 Array of uninitialized (arbitrary) data with the same
|
Chris@87
|
809 shape and type as `a`.
|
Chris@87
|
810
|
Chris@87
|
811 See Also
|
Chris@87
|
812 --------
|
Chris@87
|
813 ones_like : Return an array of ones with shape and type of input.
|
Chris@87
|
814 zeros_like : Return an array of zeros with shape and type of input.
|
Chris@87
|
815 empty : Return a new uninitialized array.
|
Chris@87
|
816 ones : Return a new array setting values to one.
|
Chris@87
|
817 zeros : Return a new array setting values to zero.
|
Chris@87
|
818
|
Chris@87
|
819 Notes
|
Chris@87
|
820 -----
|
Chris@87
|
821 This function does *not* initialize the returned array; to do that use
|
Chris@87
|
822 `zeros_like` or `ones_like` instead. It may be marginally faster than
|
Chris@87
|
823 the functions that do set the array values.
|
Chris@87
|
824
|
Chris@87
|
825 Examples
|
Chris@87
|
826 --------
|
Chris@87
|
827 >>> a = ([1,2,3], [4,5,6]) # a is array-like
|
Chris@87
|
828 >>> np.empty_like(a)
|
Chris@87
|
829 array([[-1073741821, -1073741821, 3], #random
|
Chris@87
|
830 [ 0, 0, -1073741821]])
|
Chris@87
|
831 >>> a = np.array([[1., 2., 3.],[4.,5.,6.]])
|
Chris@87
|
832 >>> np.empty_like(a)
|
Chris@87
|
833 array([[ -2.00000715e+000, 1.48219694e-323, -2.00000572e+000],#random
|
Chris@87
|
834 [ 4.38791518e-305, -2.00000715e+000, 4.17269252e-309]])
|
Chris@87
|
835
|
Chris@87
|
836 """)
|
Chris@87
|
837
|
Chris@87
|
838
|
Chris@87
|
839 add_newdoc('numpy.core.multiarray', 'scalar',
|
Chris@87
|
840 """
|
Chris@87
|
841 scalar(dtype, obj)
|
Chris@87
|
842
|
Chris@87
|
843 Return a new scalar array of the given type initialized with obj.
|
Chris@87
|
844
|
Chris@87
|
845 This function is meant mainly for pickle support. `dtype` must be a
|
Chris@87
|
846 valid data-type descriptor. If `dtype` corresponds to an object
|
Chris@87
|
847 descriptor, then `obj` can be any object, otherwise `obj` must be a
|
Chris@87
|
848 string. If `obj` is not given, it will be interpreted as None for object
|
Chris@87
|
849 type and as zeros for all other types.
|
Chris@87
|
850
|
Chris@87
|
851 """)
|
Chris@87
|
852
|
Chris@87
|
853 add_newdoc('numpy.core.multiarray', 'zeros',
|
Chris@87
|
854 """
|
Chris@87
|
855 zeros(shape, dtype=float, order='C')
|
Chris@87
|
856
|
Chris@87
|
857 Return a new array of given shape and type, filled with zeros.
|
Chris@87
|
858
|
Chris@87
|
859 Parameters
|
Chris@87
|
860 ----------
|
Chris@87
|
861 shape : int or sequence of ints
|
Chris@87
|
862 Shape of the new array, e.g., ``(2, 3)`` or ``2``.
|
Chris@87
|
863 dtype : data-type, optional
|
Chris@87
|
864 The desired data-type for the array, e.g., `numpy.int8`. Default is
|
Chris@87
|
865 `numpy.float64`.
|
Chris@87
|
866 order : {'C', 'F'}, optional
|
Chris@87
|
867 Whether to store multidimensional data in C- or Fortran-contiguous
|
Chris@87
|
868 (row- or column-wise) order in memory.
|
Chris@87
|
869
|
Chris@87
|
870 Returns
|
Chris@87
|
871 -------
|
Chris@87
|
872 out : ndarray
|
Chris@87
|
873 Array of zeros with the given shape, dtype, and order.
|
Chris@87
|
874
|
Chris@87
|
875 See Also
|
Chris@87
|
876 --------
|
Chris@87
|
877 zeros_like : Return an array of zeros with shape and type of input.
|
Chris@87
|
878 ones_like : Return an array of ones with shape and type of input.
|
Chris@87
|
879 empty_like : Return an empty array with shape and type of input.
|
Chris@87
|
880 ones : Return a new array setting values to one.
|
Chris@87
|
881 empty : Return a new uninitialized array.
|
Chris@87
|
882
|
Chris@87
|
883 Examples
|
Chris@87
|
884 --------
|
Chris@87
|
885 >>> np.zeros(5)
|
Chris@87
|
886 array([ 0., 0., 0., 0., 0.])
|
Chris@87
|
887
|
Chris@87
|
888 >>> np.zeros((5,), dtype=numpy.int)
|
Chris@87
|
889 array([0, 0, 0, 0, 0])
|
Chris@87
|
890
|
Chris@87
|
891 >>> np.zeros((2, 1))
|
Chris@87
|
892 array([[ 0.],
|
Chris@87
|
893 [ 0.]])
|
Chris@87
|
894
|
Chris@87
|
895 >>> s = (2,2)
|
Chris@87
|
896 >>> np.zeros(s)
|
Chris@87
|
897 array([[ 0., 0.],
|
Chris@87
|
898 [ 0., 0.]])
|
Chris@87
|
899
|
Chris@87
|
900 >>> np.zeros((2,), dtype=[('x', 'i4'), ('y', 'i4')]) # custom dtype
|
Chris@87
|
901 array([(0, 0), (0, 0)],
|
Chris@87
|
902 dtype=[('x', '<i4'), ('y', '<i4')])
|
Chris@87
|
903
|
Chris@87
|
904 """)
|
Chris@87
|
905
|
Chris@87
|
906 add_newdoc('numpy.core.multiarray', 'count_nonzero',
|
Chris@87
|
907 """
|
Chris@87
|
908 count_nonzero(a)
|
Chris@87
|
909
|
Chris@87
|
910 Counts the number of non-zero values in the array ``a``.
|
Chris@87
|
911
|
Chris@87
|
912 Parameters
|
Chris@87
|
913 ----------
|
Chris@87
|
914 a : array_like
|
Chris@87
|
915 The array for which to count non-zeros.
|
Chris@87
|
916
|
Chris@87
|
917 Returns
|
Chris@87
|
918 -------
|
Chris@87
|
919 count : int or array of int
|
Chris@87
|
920 Number of non-zero values in the array.
|
Chris@87
|
921
|
Chris@87
|
922 See Also
|
Chris@87
|
923 --------
|
Chris@87
|
924 nonzero : Return the coordinates of all the non-zero values.
|
Chris@87
|
925
|
Chris@87
|
926 Examples
|
Chris@87
|
927 --------
|
Chris@87
|
928 >>> np.count_nonzero(np.eye(4))
|
Chris@87
|
929 4
|
Chris@87
|
930 >>> np.count_nonzero([[0,1,7,0,0],[3,0,0,2,19]])
|
Chris@87
|
931 5
|
Chris@87
|
932 """)
|
Chris@87
|
933
|
Chris@87
|
934 add_newdoc('numpy.core.multiarray', 'set_typeDict',
|
Chris@87
|
935 """set_typeDict(dict)
|
Chris@87
|
936
|
Chris@87
|
937 Set the internal dictionary that can look up an array type using a
|
Chris@87
|
938 registered code.
|
Chris@87
|
939
|
Chris@87
|
940 """)
|
Chris@87
|
941
|
Chris@87
|
942 add_newdoc('numpy.core.multiarray', 'fromstring',
|
Chris@87
|
943 """
|
Chris@87
|
944 fromstring(string, dtype=float, count=-1, sep='')
|
Chris@87
|
945
|
Chris@87
|
946 A new 1-D array initialized from raw binary or text data in a string.
|
Chris@87
|
947
|
Chris@87
|
948 Parameters
|
Chris@87
|
949 ----------
|
Chris@87
|
950 string : str
|
Chris@87
|
951 A string containing the data.
|
Chris@87
|
952 dtype : data-type, optional
|
Chris@87
|
953 The data type of the array; default: float. For binary input data,
|
Chris@87
|
954 the data must be in exactly this format.
|
Chris@87
|
955 count : int, optional
|
Chris@87
|
956 Read this number of `dtype` elements from the data. If this is
|
Chris@87
|
957 negative (the default), the count will be determined from the
|
Chris@87
|
958 length of the data.
|
Chris@87
|
959 sep : str, optional
|
Chris@87
|
960 If not provided or, equivalently, the empty string, the data will
|
Chris@87
|
961 be interpreted as binary data; otherwise, as ASCII text with
|
Chris@87
|
962 decimal numbers. Also in this latter case, this argument is
|
Chris@87
|
963 interpreted as the string separating numbers in the data; extra
|
Chris@87
|
964 whitespace between elements is also ignored.
|
Chris@87
|
965
|
Chris@87
|
966 Returns
|
Chris@87
|
967 -------
|
Chris@87
|
968 arr : ndarray
|
Chris@87
|
969 The constructed array.
|
Chris@87
|
970
|
Chris@87
|
971 Raises
|
Chris@87
|
972 ------
|
Chris@87
|
973 ValueError
|
Chris@87
|
974 If the string is not the correct size to satisfy the requested
|
Chris@87
|
975 `dtype` and `count`.
|
Chris@87
|
976
|
Chris@87
|
977 See Also
|
Chris@87
|
978 --------
|
Chris@87
|
979 frombuffer, fromfile, fromiter
|
Chris@87
|
980
|
Chris@87
|
981 Examples
|
Chris@87
|
982 --------
|
Chris@87
|
983 >>> np.fromstring('\\x01\\x02', dtype=np.uint8)
|
Chris@87
|
984 array([1, 2], dtype=uint8)
|
Chris@87
|
985 >>> np.fromstring('1 2', dtype=int, sep=' ')
|
Chris@87
|
986 array([1, 2])
|
Chris@87
|
987 >>> np.fromstring('1, 2', dtype=int, sep=',')
|
Chris@87
|
988 array([1, 2])
|
Chris@87
|
989 >>> np.fromstring('\\x01\\x02\\x03\\x04\\x05', dtype=np.uint8, count=3)
|
Chris@87
|
990 array([1, 2, 3], dtype=uint8)
|
Chris@87
|
991
|
Chris@87
|
992 """)
|
Chris@87
|
993
|
Chris@87
|
994 add_newdoc('numpy.core.multiarray', 'fromiter',
|
Chris@87
|
995 """
|
Chris@87
|
996 fromiter(iterable, dtype, count=-1)
|
Chris@87
|
997
|
Chris@87
|
998 Create a new 1-dimensional array from an iterable object.
|
Chris@87
|
999
|
Chris@87
|
1000 Parameters
|
Chris@87
|
1001 ----------
|
Chris@87
|
1002 iterable : iterable object
|
Chris@87
|
1003 An iterable object providing data for the array.
|
Chris@87
|
1004 dtype : data-type
|
Chris@87
|
1005 The data-type of the returned array.
|
Chris@87
|
1006 count : int, optional
|
Chris@87
|
1007 The number of items to read from *iterable*. The default is -1,
|
Chris@87
|
1008 which means all data is read.
|
Chris@87
|
1009
|
Chris@87
|
1010 Returns
|
Chris@87
|
1011 -------
|
Chris@87
|
1012 out : ndarray
|
Chris@87
|
1013 The output array.
|
Chris@87
|
1014
|
Chris@87
|
1015 Notes
|
Chris@87
|
1016 -----
|
Chris@87
|
1017 Specify `count` to improve performance. It allows ``fromiter`` to
|
Chris@87
|
1018 pre-allocate the output array, instead of resizing it on demand.
|
Chris@87
|
1019
|
Chris@87
|
1020 Examples
|
Chris@87
|
1021 --------
|
Chris@87
|
1022 >>> iterable = (x*x for x in range(5))
|
Chris@87
|
1023 >>> np.fromiter(iterable, np.float)
|
Chris@87
|
1024 array([ 0., 1., 4., 9., 16.])
|
Chris@87
|
1025
|
Chris@87
|
1026 """)
|
Chris@87
|
1027
|
Chris@87
|
1028 add_newdoc('numpy.core.multiarray', 'fromfile',
|
Chris@87
|
1029 """
|
Chris@87
|
1030 fromfile(file, dtype=float, count=-1, sep='')
|
Chris@87
|
1031
|
Chris@87
|
1032 Construct an array from data in a text or binary file.
|
Chris@87
|
1033
|
Chris@87
|
1034 A highly efficient way of reading binary data with a known data-type,
|
Chris@87
|
1035 as well as parsing simply formatted text files. Data written using the
|
Chris@87
|
1036 `tofile` method can be read using this function.
|
Chris@87
|
1037
|
Chris@87
|
1038 Parameters
|
Chris@87
|
1039 ----------
|
Chris@87
|
1040 file : file or str
|
Chris@87
|
1041 Open file object or filename.
|
Chris@87
|
1042 dtype : data-type
|
Chris@87
|
1043 Data type of the returned array.
|
Chris@87
|
1044 For binary files, it is used to determine the size and byte-order
|
Chris@87
|
1045 of the items in the file.
|
Chris@87
|
1046 count : int
|
Chris@87
|
1047 Number of items to read. ``-1`` means all items (i.e., the complete
|
Chris@87
|
1048 file).
|
Chris@87
|
1049 sep : str
|
Chris@87
|
1050 Separator between items if file is a text file.
|
Chris@87
|
1051 Empty ("") separator means the file should be treated as binary.
|
Chris@87
|
1052 Spaces (" ") in the separator match zero or more whitespace characters.
|
Chris@87
|
1053 A separator consisting only of spaces must match at least one
|
Chris@87
|
1054 whitespace.
|
Chris@87
|
1055
|
Chris@87
|
1056 See also
|
Chris@87
|
1057 --------
|
Chris@87
|
1058 load, save
|
Chris@87
|
1059 ndarray.tofile
|
Chris@87
|
1060 loadtxt : More flexible way of loading data from a text file.
|
Chris@87
|
1061
|
Chris@87
|
1062 Notes
|
Chris@87
|
1063 -----
|
Chris@87
|
1064 Do not rely on the combination of `tofile` and `fromfile` for
|
Chris@87
|
1065 data storage, as the binary files generated are are not platform
|
Chris@87
|
1066 independent. In particular, no byte-order or data-type information is
|
Chris@87
|
1067 saved. Data can be stored in the platform independent ``.npy`` format
|
Chris@87
|
1068 using `save` and `load` instead.
|
Chris@87
|
1069
|
Chris@87
|
1070 Examples
|
Chris@87
|
1071 --------
|
Chris@87
|
1072 Construct an ndarray:
|
Chris@87
|
1073
|
Chris@87
|
1074 >>> dt = np.dtype([('time', [('min', int), ('sec', int)]),
|
Chris@87
|
1075 ... ('temp', float)])
|
Chris@87
|
1076 >>> x = np.zeros((1,), dtype=dt)
|
Chris@87
|
1077 >>> x['time']['min'] = 10; x['temp'] = 98.25
|
Chris@87
|
1078 >>> x
|
Chris@87
|
1079 array([((10, 0), 98.25)],
|
Chris@87
|
1080 dtype=[('time', [('min', '<i4'), ('sec', '<i4')]), ('temp', '<f8')])
|
Chris@87
|
1081
|
Chris@87
|
1082 Save the raw data to disk:
|
Chris@87
|
1083
|
Chris@87
|
1084 >>> import os
|
Chris@87
|
1085 >>> fname = os.tmpnam()
|
Chris@87
|
1086 >>> x.tofile(fname)
|
Chris@87
|
1087
|
Chris@87
|
1088 Read the raw data from disk:
|
Chris@87
|
1089
|
Chris@87
|
1090 >>> np.fromfile(fname, dtype=dt)
|
Chris@87
|
1091 array([((10, 0), 98.25)],
|
Chris@87
|
1092 dtype=[('time', [('min', '<i4'), ('sec', '<i4')]), ('temp', '<f8')])
|
Chris@87
|
1093
|
Chris@87
|
1094 The recommended way to store and load data:
|
Chris@87
|
1095
|
Chris@87
|
1096 >>> np.save(fname, x)
|
Chris@87
|
1097 >>> np.load(fname + '.npy')
|
Chris@87
|
1098 array([((10, 0), 98.25)],
|
Chris@87
|
1099 dtype=[('time', [('min', '<i4'), ('sec', '<i4')]), ('temp', '<f8')])
|
Chris@87
|
1100
|
Chris@87
|
1101 """)
|
Chris@87
|
1102
|
Chris@87
|
1103 add_newdoc('numpy.core.multiarray', 'frombuffer',
|
Chris@87
|
1104 """
|
Chris@87
|
1105 frombuffer(buffer, dtype=float, count=-1, offset=0)
|
Chris@87
|
1106
|
Chris@87
|
1107 Interpret a buffer as a 1-dimensional array.
|
Chris@87
|
1108
|
Chris@87
|
1109 Parameters
|
Chris@87
|
1110 ----------
|
Chris@87
|
1111 buffer : buffer_like
|
Chris@87
|
1112 An object that exposes the buffer interface.
|
Chris@87
|
1113 dtype : data-type, optional
|
Chris@87
|
1114 Data-type of the returned array; default: float.
|
Chris@87
|
1115 count : int, optional
|
Chris@87
|
1116 Number of items to read. ``-1`` means all data in the buffer.
|
Chris@87
|
1117 offset : int, optional
|
Chris@87
|
1118 Start reading the buffer from this offset; default: 0.
|
Chris@87
|
1119
|
Chris@87
|
1120 Notes
|
Chris@87
|
1121 -----
|
Chris@87
|
1122 If the buffer has data that is not in machine byte-order, this should
|
Chris@87
|
1123 be specified as part of the data-type, e.g.::
|
Chris@87
|
1124
|
Chris@87
|
1125 >>> dt = np.dtype(int)
|
Chris@87
|
1126 >>> dt = dt.newbyteorder('>')
|
Chris@87
|
1127 >>> np.frombuffer(buf, dtype=dt)
|
Chris@87
|
1128
|
Chris@87
|
1129 The data of the resulting array will not be byteswapped, but will be
|
Chris@87
|
1130 interpreted correctly.
|
Chris@87
|
1131
|
Chris@87
|
1132 Examples
|
Chris@87
|
1133 --------
|
Chris@87
|
1134 >>> s = 'hello world'
|
Chris@87
|
1135 >>> np.frombuffer(s, dtype='S1', count=5, offset=6)
|
Chris@87
|
1136 array(['w', 'o', 'r', 'l', 'd'],
|
Chris@87
|
1137 dtype='|S1')
|
Chris@87
|
1138
|
Chris@87
|
1139 """)
|
Chris@87
|
1140
|
Chris@87
|
1141 add_newdoc('numpy.core.multiarray', 'concatenate',
|
Chris@87
|
1142 """
|
Chris@87
|
1143 concatenate((a1, a2, ...), axis=0)
|
Chris@87
|
1144
|
Chris@87
|
1145 Join a sequence of arrays together.
|
Chris@87
|
1146
|
Chris@87
|
1147 Parameters
|
Chris@87
|
1148 ----------
|
Chris@87
|
1149 a1, a2, ... : sequence of array_like
|
Chris@87
|
1150 The arrays must have the same shape, except in the dimension
|
Chris@87
|
1151 corresponding to `axis` (the first, by default).
|
Chris@87
|
1152 axis : int, optional
|
Chris@87
|
1153 The axis along which the arrays will be joined. Default is 0.
|
Chris@87
|
1154
|
Chris@87
|
1155 Returns
|
Chris@87
|
1156 -------
|
Chris@87
|
1157 res : ndarray
|
Chris@87
|
1158 The concatenated array.
|
Chris@87
|
1159
|
Chris@87
|
1160 See Also
|
Chris@87
|
1161 --------
|
Chris@87
|
1162 ma.concatenate : Concatenate function that preserves input masks.
|
Chris@87
|
1163 array_split : Split an array into multiple sub-arrays of equal or
|
Chris@87
|
1164 near-equal size.
|
Chris@87
|
1165 split : Split array into a list of multiple sub-arrays of equal size.
|
Chris@87
|
1166 hsplit : Split array into multiple sub-arrays horizontally (column wise)
|
Chris@87
|
1167 vsplit : Split array into multiple sub-arrays vertically (row wise)
|
Chris@87
|
1168 dsplit : Split array into multiple sub-arrays along the 3rd axis (depth).
|
Chris@87
|
1169 hstack : Stack arrays in sequence horizontally (column wise)
|
Chris@87
|
1170 vstack : Stack arrays in sequence vertically (row wise)
|
Chris@87
|
1171 dstack : Stack arrays in sequence depth wise (along third dimension)
|
Chris@87
|
1172
|
Chris@87
|
1173 Notes
|
Chris@87
|
1174 -----
|
Chris@87
|
1175 When one or more of the arrays to be concatenated is a MaskedArray,
|
Chris@87
|
1176 this function will return a MaskedArray object instead of an ndarray,
|
Chris@87
|
1177 but the input masks are *not* preserved. In cases where a MaskedArray
|
Chris@87
|
1178 is expected as input, use the ma.concatenate function from the masked
|
Chris@87
|
1179 array module instead.
|
Chris@87
|
1180
|
Chris@87
|
1181 Examples
|
Chris@87
|
1182 --------
|
Chris@87
|
1183 >>> a = np.array([[1, 2], [3, 4]])
|
Chris@87
|
1184 >>> b = np.array([[5, 6]])
|
Chris@87
|
1185 >>> np.concatenate((a, b), axis=0)
|
Chris@87
|
1186 array([[1, 2],
|
Chris@87
|
1187 [3, 4],
|
Chris@87
|
1188 [5, 6]])
|
Chris@87
|
1189 >>> np.concatenate((a, b.T), axis=1)
|
Chris@87
|
1190 array([[1, 2, 5],
|
Chris@87
|
1191 [3, 4, 6]])
|
Chris@87
|
1192
|
Chris@87
|
1193 This function will not preserve masking of MaskedArray inputs.
|
Chris@87
|
1194
|
Chris@87
|
1195 >>> a = np.ma.arange(3)
|
Chris@87
|
1196 >>> a[1] = np.ma.masked
|
Chris@87
|
1197 >>> b = np.arange(2, 5)
|
Chris@87
|
1198 >>> a
|
Chris@87
|
1199 masked_array(data = [0 -- 2],
|
Chris@87
|
1200 mask = [False True False],
|
Chris@87
|
1201 fill_value = 999999)
|
Chris@87
|
1202 >>> b
|
Chris@87
|
1203 array([2, 3, 4])
|
Chris@87
|
1204 >>> np.concatenate([a, b])
|
Chris@87
|
1205 masked_array(data = [0 1 2 2 3 4],
|
Chris@87
|
1206 mask = False,
|
Chris@87
|
1207 fill_value = 999999)
|
Chris@87
|
1208 >>> np.ma.concatenate([a, b])
|
Chris@87
|
1209 masked_array(data = [0 -- 2 2 3 4],
|
Chris@87
|
1210 mask = [False True False False False False],
|
Chris@87
|
1211 fill_value = 999999)
|
Chris@87
|
1212
|
Chris@87
|
1213 """)
|
Chris@87
|
1214
|
Chris@87
|
1215 add_newdoc('numpy.core', 'inner',
|
Chris@87
|
1216 """
|
Chris@87
|
1217 inner(a, b)
|
Chris@87
|
1218
|
Chris@87
|
1219 Inner product of two arrays.
|
Chris@87
|
1220
|
Chris@87
|
1221 Ordinary inner product of vectors for 1-D arrays (without complex
|
Chris@87
|
1222 conjugation), in higher dimensions a sum product over the last axes.
|
Chris@87
|
1223
|
Chris@87
|
1224 Parameters
|
Chris@87
|
1225 ----------
|
Chris@87
|
1226 a, b : array_like
|
Chris@87
|
1227 If `a` and `b` are nonscalar, their last dimensions of must match.
|
Chris@87
|
1228
|
Chris@87
|
1229 Returns
|
Chris@87
|
1230 -------
|
Chris@87
|
1231 out : ndarray
|
Chris@87
|
1232 `out.shape = a.shape[:-1] + b.shape[:-1]`
|
Chris@87
|
1233
|
Chris@87
|
1234 Raises
|
Chris@87
|
1235 ------
|
Chris@87
|
1236 ValueError
|
Chris@87
|
1237 If the last dimension of `a` and `b` has different size.
|
Chris@87
|
1238
|
Chris@87
|
1239 See Also
|
Chris@87
|
1240 --------
|
Chris@87
|
1241 tensordot : Sum products over arbitrary axes.
|
Chris@87
|
1242 dot : Generalised matrix product, using second last dimension of `b`.
|
Chris@87
|
1243 einsum : Einstein summation convention.
|
Chris@87
|
1244
|
Chris@87
|
1245 Notes
|
Chris@87
|
1246 -----
|
Chris@87
|
1247 For vectors (1-D arrays) it computes the ordinary inner-product::
|
Chris@87
|
1248
|
Chris@87
|
1249 np.inner(a, b) = sum(a[:]*b[:])
|
Chris@87
|
1250
|
Chris@87
|
1251 More generally, if `ndim(a) = r > 0` and `ndim(b) = s > 0`::
|
Chris@87
|
1252
|
Chris@87
|
1253 np.inner(a, b) = np.tensordot(a, b, axes=(-1,-1))
|
Chris@87
|
1254
|
Chris@87
|
1255 or explicitly::
|
Chris@87
|
1256
|
Chris@87
|
1257 np.inner(a, b)[i0,...,ir-1,j0,...,js-1]
|
Chris@87
|
1258 = sum(a[i0,...,ir-1,:]*b[j0,...,js-1,:])
|
Chris@87
|
1259
|
Chris@87
|
1260 In addition `a` or `b` may be scalars, in which case::
|
Chris@87
|
1261
|
Chris@87
|
1262 np.inner(a,b) = a*b
|
Chris@87
|
1263
|
Chris@87
|
1264 Examples
|
Chris@87
|
1265 --------
|
Chris@87
|
1266 Ordinary inner product for vectors:
|
Chris@87
|
1267
|
Chris@87
|
1268 >>> a = np.array([1,2,3])
|
Chris@87
|
1269 >>> b = np.array([0,1,0])
|
Chris@87
|
1270 >>> np.inner(a, b)
|
Chris@87
|
1271 2
|
Chris@87
|
1272
|
Chris@87
|
1273 A multidimensional example:
|
Chris@87
|
1274
|
Chris@87
|
1275 >>> a = np.arange(24).reshape((2,3,4))
|
Chris@87
|
1276 >>> b = np.arange(4)
|
Chris@87
|
1277 >>> np.inner(a, b)
|
Chris@87
|
1278 array([[ 14, 38, 62],
|
Chris@87
|
1279 [ 86, 110, 134]])
|
Chris@87
|
1280
|
Chris@87
|
1281 An example where `b` is a scalar:
|
Chris@87
|
1282
|
Chris@87
|
1283 >>> np.inner(np.eye(2), 7)
|
Chris@87
|
1284 array([[ 7., 0.],
|
Chris@87
|
1285 [ 0., 7.]])
|
Chris@87
|
1286
|
Chris@87
|
1287 """)
|
Chris@87
|
1288
|
Chris@87
|
1289 add_newdoc('numpy.core', 'fastCopyAndTranspose',
|
Chris@87
|
1290 """_fastCopyAndTranspose(a)""")
|
Chris@87
|
1291
|
Chris@87
|
1292 add_newdoc('numpy.core.multiarray', 'correlate',
|
Chris@87
|
1293 """cross_correlate(a,v, mode=0)""")
|
Chris@87
|
1294
|
Chris@87
|
1295 add_newdoc('numpy.core.multiarray', 'arange',
|
Chris@87
|
1296 """
|
Chris@87
|
1297 arange([start,] stop[, step,], dtype=None)
|
Chris@87
|
1298
|
Chris@87
|
1299 Return evenly spaced values within a given interval.
|
Chris@87
|
1300
|
Chris@87
|
1301 Values are generated within the half-open interval ``[start, stop)``
|
Chris@87
|
1302 (in other words, the interval including `start` but excluding `stop`).
|
Chris@87
|
1303 For integer arguments the function is equivalent to the Python built-in
|
Chris@87
|
1304 `range <http://docs.python.org/lib/built-in-funcs.html>`_ function,
|
Chris@87
|
1305 but returns an ndarray rather than a list.
|
Chris@87
|
1306
|
Chris@87
|
1307 When using a non-integer step, such as 0.1, the results will often not
|
Chris@87
|
1308 be consistent. It is better to use ``linspace`` for these cases.
|
Chris@87
|
1309
|
Chris@87
|
1310 Parameters
|
Chris@87
|
1311 ----------
|
Chris@87
|
1312 start : number, optional
|
Chris@87
|
1313 Start of interval. The interval includes this value. The default
|
Chris@87
|
1314 start value is 0.
|
Chris@87
|
1315 stop : number
|
Chris@87
|
1316 End of interval. The interval does not include this value, except
|
Chris@87
|
1317 in some cases where `step` is not an integer and floating point
|
Chris@87
|
1318 round-off affects the length of `out`.
|
Chris@87
|
1319 step : number, optional
|
Chris@87
|
1320 Spacing between values. For any output `out`, this is the distance
|
Chris@87
|
1321 between two adjacent values, ``out[i+1] - out[i]``. The default
|
Chris@87
|
1322 step size is 1. If `step` is specified, `start` must also be given.
|
Chris@87
|
1323 dtype : dtype
|
Chris@87
|
1324 The type of the output array. If `dtype` is not given, infer the data
|
Chris@87
|
1325 type from the other input arguments.
|
Chris@87
|
1326
|
Chris@87
|
1327 Returns
|
Chris@87
|
1328 -------
|
Chris@87
|
1329 arange : ndarray
|
Chris@87
|
1330 Array of evenly spaced values.
|
Chris@87
|
1331
|
Chris@87
|
1332 For floating point arguments, the length of the result is
|
Chris@87
|
1333 ``ceil((stop - start)/step)``. Because of floating point overflow,
|
Chris@87
|
1334 this rule may result in the last element of `out` being greater
|
Chris@87
|
1335 than `stop`.
|
Chris@87
|
1336
|
Chris@87
|
1337 See Also
|
Chris@87
|
1338 --------
|
Chris@87
|
1339 linspace : Evenly spaced numbers with careful handling of endpoints.
|
Chris@87
|
1340 ogrid: Arrays of evenly spaced numbers in N-dimensions.
|
Chris@87
|
1341 mgrid: Grid-shaped arrays of evenly spaced numbers in N-dimensions.
|
Chris@87
|
1342
|
Chris@87
|
1343 Examples
|
Chris@87
|
1344 --------
|
Chris@87
|
1345 >>> np.arange(3)
|
Chris@87
|
1346 array([0, 1, 2])
|
Chris@87
|
1347 >>> np.arange(3.0)
|
Chris@87
|
1348 array([ 0., 1., 2.])
|
Chris@87
|
1349 >>> np.arange(3,7)
|
Chris@87
|
1350 array([3, 4, 5, 6])
|
Chris@87
|
1351 >>> np.arange(3,7,2)
|
Chris@87
|
1352 array([3, 5])
|
Chris@87
|
1353
|
Chris@87
|
1354 """)
|
Chris@87
|
1355
|
Chris@87
|
1356 add_newdoc('numpy.core.multiarray', '_get_ndarray_c_version',
|
Chris@87
|
1357 """_get_ndarray_c_version()
|
Chris@87
|
1358
|
Chris@87
|
1359 Return the compile time NDARRAY_VERSION number.
|
Chris@87
|
1360
|
Chris@87
|
1361 """)
|
Chris@87
|
1362
|
Chris@87
|
1363 add_newdoc('numpy.core.multiarray', '_reconstruct',
|
Chris@87
|
1364 """_reconstruct(subtype, shape, dtype)
|
Chris@87
|
1365
|
Chris@87
|
1366 Construct an empty array. Used by Pickles.
|
Chris@87
|
1367
|
Chris@87
|
1368 """)
|
Chris@87
|
1369
|
Chris@87
|
1370
|
Chris@87
|
1371 add_newdoc('numpy.core.multiarray', 'set_string_function',
|
Chris@87
|
1372 """
|
Chris@87
|
1373 set_string_function(f, repr=1)
|
Chris@87
|
1374
|
Chris@87
|
1375 Internal method to set a function to be used when pretty printing arrays.
|
Chris@87
|
1376
|
Chris@87
|
1377 """)
|
Chris@87
|
1378
|
Chris@87
|
1379 add_newdoc('numpy.core.multiarray', 'set_numeric_ops',
|
Chris@87
|
1380 """
|
Chris@87
|
1381 set_numeric_ops(op1=func1, op2=func2, ...)
|
Chris@87
|
1382
|
Chris@87
|
1383 Set numerical operators for array objects.
|
Chris@87
|
1384
|
Chris@87
|
1385 Parameters
|
Chris@87
|
1386 ----------
|
Chris@87
|
1387 op1, op2, ... : callable
|
Chris@87
|
1388 Each ``op = func`` pair describes an operator to be replaced.
|
Chris@87
|
1389 For example, ``add = lambda x, y: np.add(x, y) % 5`` would replace
|
Chris@87
|
1390 addition by modulus 5 addition.
|
Chris@87
|
1391
|
Chris@87
|
1392 Returns
|
Chris@87
|
1393 -------
|
Chris@87
|
1394 saved_ops : list of callables
|
Chris@87
|
1395 A list of all operators, stored before making replacements.
|
Chris@87
|
1396
|
Chris@87
|
1397 Notes
|
Chris@87
|
1398 -----
|
Chris@87
|
1399 .. WARNING::
|
Chris@87
|
1400 Use with care! Incorrect usage may lead to memory errors.
|
Chris@87
|
1401
|
Chris@87
|
1402 A function replacing an operator cannot make use of that operator.
|
Chris@87
|
1403 For example, when replacing add, you may not use ``+``. Instead,
|
Chris@87
|
1404 directly call ufuncs.
|
Chris@87
|
1405
|
Chris@87
|
1406 Examples
|
Chris@87
|
1407 --------
|
Chris@87
|
1408 >>> def add_mod5(x, y):
|
Chris@87
|
1409 ... return np.add(x, y) % 5
|
Chris@87
|
1410 ...
|
Chris@87
|
1411 >>> old_funcs = np.set_numeric_ops(add=add_mod5)
|
Chris@87
|
1412
|
Chris@87
|
1413 >>> x = np.arange(12).reshape((3, 4))
|
Chris@87
|
1414 >>> x + x
|
Chris@87
|
1415 array([[0, 2, 4, 1],
|
Chris@87
|
1416 [3, 0, 2, 4],
|
Chris@87
|
1417 [1, 3, 0, 2]])
|
Chris@87
|
1418
|
Chris@87
|
1419 >>> ignore = np.set_numeric_ops(**old_funcs) # restore operators
|
Chris@87
|
1420
|
Chris@87
|
1421 """)
|
Chris@87
|
1422
|
Chris@87
|
1423 add_newdoc('numpy.core.multiarray', 'where',
|
Chris@87
|
1424 """
|
Chris@87
|
1425 where(condition, [x, y])
|
Chris@87
|
1426
|
Chris@87
|
1427 Return elements, either from `x` or `y`, depending on `condition`.
|
Chris@87
|
1428
|
Chris@87
|
1429 If only `condition` is given, return ``condition.nonzero()``.
|
Chris@87
|
1430
|
Chris@87
|
1431 Parameters
|
Chris@87
|
1432 ----------
|
Chris@87
|
1433 condition : array_like, bool
|
Chris@87
|
1434 When True, yield `x`, otherwise yield `y`.
|
Chris@87
|
1435 x, y : array_like, optional
|
Chris@87
|
1436 Values from which to choose. `x` and `y` need to have the same
|
Chris@87
|
1437 shape as `condition`.
|
Chris@87
|
1438
|
Chris@87
|
1439 Returns
|
Chris@87
|
1440 -------
|
Chris@87
|
1441 out : ndarray or tuple of ndarrays
|
Chris@87
|
1442 If both `x` and `y` are specified, the output array contains
|
Chris@87
|
1443 elements of `x` where `condition` is True, and elements from
|
Chris@87
|
1444 `y` elsewhere.
|
Chris@87
|
1445
|
Chris@87
|
1446 If only `condition` is given, return the tuple
|
Chris@87
|
1447 ``condition.nonzero()``, the indices where `condition` is True.
|
Chris@87
|
1448
|
Chris@87
|
1449 See Also
|
Chris@87
|
1450 --------
|
Chris@87
|
1451 nonzero, choose
|
Chris@87
|
1452
|
Chris@87
|
1453 Notes
|
Chris@87
|
1454 -----
|
Chris@87
|
1455 If `x` and `y` are given and input arrays are 1-D, `where` is
|
Chris@87
|
1456 equivalent to::
|
Chris@87
|
1457
|
Chris@87
|
1458 [xv if c else yv for (c,xv,yv) in zip(condition,x,y)]
|
Chris@87
|
1459
|
Chris@87
|
1460 Examples
|
Chris@87
|
1461 --------
|
Chris@87
|
1462 >>> np.where([[True, False], [True, True]],
|
Chris@87
|
1463 ... [[1, 2], [3, 4]],
|
Chris@87
|
1464 ... [[9, 8], [7, 6]])
|
Chris@87
|
1465 array([[1, 8],
|
Chris@87
|
1466 [3, 4]])
|
Chris@87
|
1467
|
Chris@87
|
1468 >>> np.where([[0, 1], [1, 0]])
|
Chris@87
|
1469 (array([0, 1]), array([1, 0]))
|
Chris@87
|
1470
|
Chris@87
|
1471 >>> x = np.arange(9.).reshape(3, 3)
|
Chris@87
|
1472 >>> np.where( x > 5 )
|
Chris@87
|
1473 (array([2, 2, 2]), array([0, 1, 2]))
|
Chris@87
|
1474 >>> x[np.where( x > 3.0 )] # Note: result is 1D.
|
Chris@87
|
1475 array([ 4., 5., 6., 7., 8.])
|
Chris@87
|
1476 >>> np.where(x < 5, x, -1) # Note: broadcasting.
|
Chris@87
|
1477 array([[ 0., 1., 2.],
|
Chris@87
|
1478 [ 3., 4., -1.],
|
Chris@87
|
1479 [-1., -1., -1.]])
|
Chris@87
|
1480
|
Chris@87
|
1481 Find the indices of elements of `x` that are in `goodvalues`.
|
Chris@87
|
1482
|
Chris@87
|
1483 >>> goodvalues = [3, 4, 7]
|
Chris@87
|
1484 >>> ix = np.in1d(x.ravel(), goodvalues).reshape(x.shape)
|
Chris@87
|
1485 >>> ix
|
Chris@87
|
1486 array([[False, False, False],
|
Chris@87
|
1487 [ True, True, False],
|
Chris@87
|
1488 [False, True, False]], dtype=bool)
|
Chris@87
|
1489 >>> np.where(ix)
|
Chris@87
|
1490 (array([1, 1, 2]), array([0, 1, 1]))
|
Chris@87
|
1491
|
Chris@87
|
1492 """)
|
Chris@87
|
1493
|
Chris@87
|
1494
|
Chris@87
|
1495 add_newdoc('numpy.core.multiarray', 'lexsort',
|
Chris@87
|
1496 """
|
Chris@87
|
1497 lexsort(keys, axis=-1)
|
Chris@87
|
1498
|
Chris@87
|
1499 Perform an indirect sort using a sequence of keys.
|
Chris@87
|
1500
|
Chris@87
|
1501 Given multiple sorting keys, which can be interpreted as columns in a
|
Chris@87
|
1502 spreadsheet, lexsort returns an array of integer indices that describes
|
Chris@87
|
1503 the sort order by multiple columns. The last key in the sequence is used
|
Chris@87
|
1504 for the primary sort order, the second-to-last key for the secondary sort
|
Chris@87
|
1505 order, and so on. The keys argument must be a sequence of objects that
|
Chris@87
|
1506 can be converted to arrays of the same shape. If a 2D array is provided
|
Chris@87
|
1507 for the keys argument, it's rows are interpreted as the sorting keys and
|
Chris@87
|
1508 sorting is according to the last row, second last row etc.
|
Chris@87
|
1509
|
Chris@87
|
1510 Parameters
|
Chris@87
|
1511 ----------
|
Chris@87
|
1512 keys : (k, N) array or tuple containing k (N,)-shaped sequences
|
Chris@87
|
1513 The `k` different "columns" to be sorted. The last column (or row if
|
Chris@87
|
1514 `keys` is a 2D array) is the primary sort key.
|
Chris@87
|
1515 axis : int, optional
|
Chris@87
|
1516 Axis to be indirectly sorted. By default, sort over the last axis.
|
Chris@87
|
1517
|
Chris@87
|
1518 Returns
|
Chris@87
|
1519 -------
|
Chris@87
|
1520 indices : (N,) ndarray of ints
|
Chris@87
|
1521 Array of indices that sort the keys along the specified axis.
|
Chris@87
|
1522
|
Chris@87
|
1523 See Also
|
Chris@87
|
1524 --------
|
Chris@87
|
1525 argsort : Indirect sort.
|
Chris@87
|
1526 ndarray.sort : In-place sort.
|
Chris@87
|
1527 sort : Return a sorted copy of an array.
|
Chris@87
|
1528
|
Chris@87
|
1529 Examples
|
Chris@87
|
1530 --------
|
Chris@87
|
1531 Sort names: first by surname, then by name.
|
Chris@87
|
1532
|
Chris@87
|
1533 >>> surnames = ('Hertz', 'Galilei', 'Hertz')
|
Chris@87
|
1534 >>> first_names = ('Heinrich', 'Galileo', 'Gustav')
|
Chris@87
|
1535 >>> ind = np.lexsort((first_names, surnames))
|
Chris@87
|
1536 >>> ind
|
Chris@87
|
1537 array([1, 2, 0])
|
Chris@87
|
1538
|
Chris@87
|
1539 >>> [surnames[i] + ", " + first_names[i] for i in ind]
|
Chris@87
|
1540 ['Galilei, Galileo', 'Hertz, Gustav', 'Hertz, Heinrich']
|
Chris@87
|
1541
|
Chris@87
|
1542 Sort two columns of numbers:
|
Chris@87
|
1543
|
Chris@87
|
1544 >>> a = [1,5,1,4,3,4,4] # First column
|
Chris@87
|
1545 >>> b = [9,4,0,4,0,2,1] # Second column
|
Chris@87
|
1546 >>> ind = np.lexsort((b,a)) # Sort by a, then by b
|
Chris@87
|
1547 >>> print ind
|
Chris@87
|
1548 [2 0 4 6 5 3 1]
|
Chris@87
|
1549
|
Chris@87
|
1550 >>> [(a[i],b[i]) for i in ind]
|
Chris@87
|
1551 [(1, 0), (1, 9), (3, 0), (4, 1), (4, 2), (4, 4), (5, 4)]
|
Chris@87
|
1552
|
Chris@87
|
1553 Note that sorting is first according to the elements of ``a``.
|
Chris@87
|
1554 Secondary sorting is according to the elements of ``b``.
|
Chris@87
|
1555
|
Chris@87
|
1556 A normal ``argsort`` would have yielded:
|
Chris@87
|
1557
|
Chris@87
|
1558 >>> [(a[i],b[i]) for i in np.argsort(a)]
|
Chris@87
|
1559 [(1, 9), (1, 0), (3, 0), (4, 4), (4, 2), (4, 1), (5, 4)]
|
Chris@87
|
1560
|
Chris@87
|
1561 Structured arrays are sorted lexically by ``argsort``:
|
Chris@87
|
1562
|
Chris@87
|
1563 >>> x = np.array([(1,9), (5,4), (1,0), (4,4), (3,0), (4,2), (4,1)],
|
Chris@87
|
1564 ... dtype=np.dtype([('x', int), ('y', int)]))
|
Chris@87
|
1565
|
Chris@87
|
1566 >>> np.argsort(x) # or np.argsort(x, order=('x', 'y'))
|
Chris@87
|
1567 array([2, 0, 4, 6, 5, 3, 1])
|
Chris@87
|
1568
|
Chris@87
|
1569 """)
|
Chris@87
|
1570
|
Chris@87
|
1571 add_newdoc('numpy.core.multiarray', 'can_cast',
|
Chris@87
|
1572 """
|
Chris@87
|
1573 can_cast(from, totype, casting = 'safe')
|
Chris@87
|
1574
|
Chris@87
|
1575 Returns True if cast between data types can occur according to the
|
Chris@87
|
1576 casting rule. If from is a scalar or array scalar, also returns
|
Chris@87
|
1577 True if the scalar value can be cast without overflow or truncation
|
Chris@87
|
1578 to an integer.
|
Chris@87
|
1579
|
Chris@87
|
1580 Parameters
|
Chris@87
|
1581 ----------
|
Chris@87
|
1582 from : dtype, dtype specifier, scalar, or array
|
Chris@87
|
1583 Data type, scalar, or array to cast from.
|
Chris@87
|
1584 totype : dtype or dtype specifier
|
Chris@87
|
1585 Data type to cast to.
|
Chris@87
|
1586 casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
|
Chris@87
|
1587 Controls what kind of data casting may occur.
|
Chris@87
|
1588
|
Chris@87
|
1589 * 'no' means the data types should not be cast at all.
|
Chris@87
|
1590 * 'equiv' means only byte-order changes are allowed.
|
Chris@87
|
1591 * 'safe' means only casts which can preserve values are allowed.
|
Chris@87
|
1592 * 'same_kind' means only safe casts or casts within a kind,
|
Chris@87
|
1593 like float64 to float32, are allowed.
|
Chris@87
|
1594 * 'unsafe' means any data conversions may be done.
|
Chris@87
|
1595
|
Chris@87
|
1596 Returns
|
Chris@87
|
1597 -------
|
Chris@87
|
1598 out : bool
|
Chris@87
|
1599 True if cast can occur according to the casting rule.
|
Chris@87
|
1600
|
Chris@87
|
1601 Notes
|
Chris@87
|
1602 -----
|
Chris@87
|
1603 Starting in NumPy 1.9, can_cast function now returns False in 'safe'
|
Chris@87
|
1604 casting mode for integer/float dtype and string dtype if the string dtype
|
Chris@87
|
1605 length is not long enough to store the max integer/float value converted
|
Chris@87
|
1606 to a string. Previously can_cast in 'safe' mode returned True for
|
Chris@87
|
1607 integer/float dtype and a string dtype of any length.
|
Chris@87
|
1608
|
Chris@87
|
1609 See also
|
Chris@87
|
1610 --------
|
Chris@87
|
1611 dtype, result_type
|
Chris@87
|
1612
|
Chris@87
|
1613 Examples
|
Chris@87
|
1614 --------
|
Chris@87
|
1615 Basic examples
|
Chris@87
|
1616
|
Chris@87
|
1617 >>> np.can_cast(np.int32, np.int64)
|
Chris@87
|
1618 True
|
Chris@87
|
1619 >>> np.can_cast(np.float64, np.complex)
|
Chris@87
|
1620 True
|
Chris@87
|
1621 >>> np.can_cast(np.complex, np.float)
|
Chris@87
|
1622 False
|
Chris@87
|
1623
|
Chris@87
|
1624 >>> np.can_cast('i8', 'f8')
|
Chris@87
|
1625 True
|
Chris@87
|
1626 >>> np.can_cast('i8', 'f4')
|
Chris@87
|
1627 False
|
Chris@87
|
1628 >>> np.can_cast('i4', 'S4')
|
Chris@87
|
1629 False
|
Chris@87
|
1630
|
Chris@87
|
1631 Casting scalars
|
Chris@87
|
1632
|
Chris@87
|
1633 >>> np.can_cast(100, 'i1')
|
Chris@87
|
1634 True
|
Chris@87
|
1635 >>> np.can_cast(150, 'i1')
|
Chris@87
|
1636 False
|
Chris@87
|
1637 >>> np.can_cast(150, 'u1')
|
Chris@87
|
1638 True
|
Chris@87
|
1639
|
Chris@87
|
1640 >>> np.can_cast(3.5e100, np.float32)
|
Chris@87
|
1641 False
|
Chris@87
|
1642 >>> np.can_cast(1000.0, np.float32)
|
Chris@87
|
1643 True
|
Chris@87
|
1644
|
Chris@87
|
1645 Array scalar checks the value, array does not
|
Chris@87
|
1646
|
Chris@87
|
1647 >>> np.can_cast(np.array(1000.0), np.float32)
|
Chris@87
|
1648 True
|
Chris@87
|
1649 >>> np.can_cast(np.array([1000.0]), np.float32)
|
Chris@87
|
1650 False
|
Chris@87
|
1651
|
Chris@87
|
1652 Using the casting rules
|
Chris@87
|
1653
|
Chris@87
|
1654 >>> np.can_cast('i8', 'i8', 'no')
|
Chris@87
|
1655 True
|
Chris@87
|
1656 >>> np.can_cast('<i8', '>i8', 'no')
|
Chris@87
|
1657 False
|
Chris@87
|
1658
|
Chris@87
|
1659 >>> np.can_cast('<i8', '>i8', 'equiv')
|
Chris@87
|
1660 True
|
Chris@87
|
1661 >>> np.can_cast('<i4', '>i8', 'equiv')
|
Chris@87
|
1662 False
|
Chris@87
|
1663
|
Chris@87
|
1664 >>> np.can_cast('<i4', '>i8', 'safe')
|
Chris@87
|
1665 True
|
Chris@87
|
1666 >>> np.can_cast('<i8', '>i4', 'safe')
|
Chris@87
|
1667 False
|
Chris@87
|
1668
|
Chris@87
|
1669 >>> np.can_cast('<i8', '>i4', 'same_kind')
|
Chris@87
|
1670 True
|
Chris@87
|
1671 >>> np.can_cast('<i8', '>u4', 'same_kind')
|
Chris@87
|
1672 False
|
Chris@87
|
1673
|
Chris@87
|
1674 >>> np.can_cast('<i8', '>u4', 'unsafe')
|
Chris@87
|
1675 True
|
Chris@87
|
1676
|
Chris@87
|
1677 """)
|
Chris@87
|
1678
|
Chris@87
|
1679 add_newdoc('numpy.core.multiarray', 'promote_types',
|
Chris@87
|
1680 """
|
Chris@87
|
1681 promote_types(type1, type2)
|
Chris@87
|
1682
|
Chris@87
|
1683 Returns the data type with the smallest size and smallest scalar
|
Chris@87
|
1684 kind to which both ``type1`` and ``type2`` may be safely cast.
|
Chris@87
|
1685 The returned data type is always in native byte order.
|
Chris@87
|
1686
|
Chris@87
|
1687 This function is symmetric and associative.
|
Chris@87
|
1688
|
Chris@87
|
1689 Parameters
|
Chris@87
|
1690 ----------
|
Chris@87
|
1691 type1 : dtype or dtype specifier
|
Chris@87
|
1692 First data type.
|
Chris@87
|
1693 type2 : dtype or dtype specifier
|
Chris@87
|
1694 Second data type.
|
Chris@87
|
1695
|
Chris@87
|
1696 Returns
|
Chris@87
|
1697 -------
|
Chris@87
|
1698 out : dtype
|
Chris@87
|
1699 The promoted data type.
|
Chris@87
|
1700
|
Chris@87
|
1701 Notes
|
Chris@87
|
1702 -----
|
Chris@87
|
1703 .. versionadded:: 1.6.0
|
Chris@87
|
1704 Starting in NumPy 1.9, promote_types function now returns a valid string
|
Chris@87
|
1705 length when given an integer or float dtype as one argument and a string
|
Chris@87
|
1706 dtype as another argument. Previously it always returned the input string
|
Chris@87
|
1707 dtype, even if it wasn't long enough to store the max integer/float value
|
Chris@87
|
1708 converted to a string.
|
Chris@87
|
1709
|
Chris@87
|
1710 See Also
|
Chris@87
|
1711 --------
|
Chris@87
|
1712 result_type, dtype, can_cast
|
Chris@87
|
1713
|
Chris@87
|
1714 Examples
|
Chris@87
|
1715 --------
|
Chris@87
|
1716 >>> np.promote_types('f4', 'f8')
|
Chris@87
|
1717 dtype('float64')
|
Chris@87
|
1718
|
Chris@87
|
1719 >>> np.promote_types('i8', 'f4')
|
Chris@87
|
1720 dtype('float64')
|
Chris@87
|
1721
|
Chris@87
|
1722 >>> np.promote_types('>i8', '<c8')
|
Chris@87
|
1723 dtype('complex128')
|
Chris@87
|
1724
|
Chris@87
|
1725 >>> np.promote_types('i4', 'S8')
|
Chris@87
|
1726 dtype('S11')
|
Chris@87
|
1727
|
Chris@87
|
1728 """)
|
Chris@87
|
1729
|
Chris@87
|
1730 add_newdoc('numpy.core.multiarray', 'min_scalar_type',
|
Chris@87
|
1731 """
|
Chris@87
|
1732 min_scalar_type(a)
|
Chris@87
|
1733
|
Chris@87
|
1734 For scalar ``a``, returns the data type with the smallest size
|
Chris@87
|
1735 and smallest scalar kind which can hold its value. For non-scalar
|
Chris@87
|
1736 array ``a``, returns the vector's dtype unmodified.
|
Chris@87
|
1737
|
Chris@87
|
1738 Floating point values are not demoted to integers,
|
Chris@87
|
1739 and complex values are not demoted to floats.
|
Chris@87
|
1740
|
Chris@87
|
1741 Parameters
|
Chris@87
|
1742 ----------
|
Chris@87
|
1743 a : scalar or array_like
|
Chris@87
|
1744 The value whose minimal data type is to be found.
|
Chris@87
|
1745
|
Chris@87
|
1746 Returns
|
Chris@87
|
1747 -------
|
Chris@87
|
1748 out : dtype
|
Chris@87
|
1749 The minimal data type.
|
Chris@87
|
1750
|
Chris@87
|
1751 Notes
|
Chris@87
|
1752 -----
|
Chris@87
|
1753 .. versionadded:: 1.6.0
|
Chris@87
|
1754
|
Chris@87
|
1755 See Also
|
Chris@87
|
1756 --------
|
Chris@87
|
1757 result_type, promote_types, dtype, can_cast
|
Chris@87
|
1758
|
Chris@87
|
1759 Examples
|
Chris@87
|
1760 --------
|
Chris@87
|
1761 >>> np.min_scalar_type(10)
|
Chris@87
|
1762 dtype('uint8')
|
Chris@87
|
1763
|
Chris@87
|
1764 >>> np.min_scalar_type(-260)
|
Chris@87
|
1765 dtype('int16')
|
Chris@87
|
1766
|
Chris@87
|
1767 >>> np.min_scalar_type(3.1)
|
Chris@87
|
1768 dtype('float16')
|
Chris@87
|
1769
|
Chris@87
|
1770 >>> np.min_scalar_type(1e50)
|
Chris@87
|
1771 dtype('float64')
|
Chris@87
|
1772
|
Chris@87
|
1773 >>> np.min_scalar_type(np.arange(4,dtype='f8'))
|
Chris@87
|
1774 dtype('float64')
|
Chris@87
|
1775
|
Chris@87
|
1776 """)
|
Chris@87
|
1777
|
Chris@87
|
1778 add_newdoc('numpy.core.multiarray', 'result_type',
|
Chris@87
|
1779 """
|
Chris@87
|
1780 result_type(*arrays_and_dtypes)
|
Chris@87
|
1781
|
Chris@87
|
1782 Returns the type that results from applying the NumPy
|
Chris@87
|
1783 type promotion rules to the arguments.
|
Chris@87
|
1784
|
Chris@87
|
1785 Type promotion in NumPy works similarly to the rules in languages
|
Chris@87
|
1786 like C++, with some slight differences. When both scalars and
|
Chris@87
|
1787 arrays are used, the array's type takes precedence and the actual value
|
Chris@87
|
1788 of the scalar is taken into account.
|
Chris@87
|
1789
|
Chris@87
|
1790 For example, calculating 3*a, where a is an array of 32-bit floats,
|
Chris@87
|
1791 intuitively should result in a 32-bit float output. If the 3 is a
|
Chris@87
|
1792 32-bit integer, the NumPy rules indicate it can't convert losslessly
|
Chris@87
|
1793 into a 32-bit float, so a 64-bit float should be the result type.
|
Chris@87
|
1794 By examining the value of the constant, '3', we see that it fits in
|
Chris@87
|
1795 an 8-bit integer, which can be cast losslessly into the 32-bit float.
|
Chris@87
|
1796
|
Chris@87
|
1797 Parameters
|
Chris@87
|
1798 ----------
|
Chris@87
|
1799 arrays_and_dtypes : list of arrays and dtypes
|
Chris@87
|
1800 The operands of some operation whose result type is needed.
|
Chris@87
|
1801
|
Chris@87
|
1802 Returns
|
Chris@87
|
1803 -------
|
Chris@87
|
1804 out : dtype
|
Chris@87
|
1805 The result type.
|
Chris@87
|
1806
|
Chris@87
|
1807 See also
|
Chris@87
|
1808 --------
|
Chris@87
|
1809 dtype, promote_types, min_scalar_type, can_cast
|
Chris@87
|
1810
|
Chris@87
|
1811 Notes
|
Chris@87
|
1812 -----
|
Chris@87
|
1813 .. versionadded:: 1.6.0
|
Chris@87
|
1814
|
Chris@87
|
1815 The specific algorithm used is as follows.
|
Chris@87
|
1816
|
Chris@87
|
1817 Categories are determined by first checking which of boolean,
|
Chris@87
|
1818 integer (int/uint), or floating point (float/complex) the maximum
|
Chris@87
|
1819 kind of all the arrays and the scalars are.
|
Chris@87
|
1820
|
Chris@87
|
1821 If there are only scalars or the maximum category of the scalars
|
Chris@87
|
1822 is higher than the maximum category of the arrays,
|
Chris@87
|
1823 the data types are combined with :func:`promote_types`
|
Chris@87
|
1824 to produce the return value.
|
Chris@87
|
1825
|
Chris@87
|
1826 Otherwise, `min_scalar_type` is called on each array, and
|
Chris@87
|
1827 the resulting data types are all combined with :func:`promote_types`
|
Chris@87
|
1828 to produce the return value.
|
Chris@87
|
1829
|
Chris@87
|
1830 The set of int values is not a subset of the uint values for types
|
Chris@87
|
1831 with the same number of bits, something not reflected in
|
Chris@87
|
1832 :func:`min_scalar_type`, but handled as a special case in `result_type`.
|
Chris@87
|
1833
|
Chris@87
|
1834 Examples
|
Chris@87
|
1835 --------
|
Chris@87
|
1836 >>> np.result_type(3, np.arange(7, dtype='i1'))
|
Chris@87
|
1837 dtype('int8')
|
Chris@87
|
1838
|
Chris@87
|
1839 >>> np.result_type('i4', 'c8')
|
Chris@87
|
1840 dtype('complex128')
|
Chris@87
|
1841
|
Chris@87
|
1842 >>> np.result_type(3.0, -2)
|
Chris@87
|
1843 dtype('float64')
|
Chris@87
|
1844
|
Chris@87
|
1845 """)
|
Chris@87
|
1846
|
Chris@87
|
1847 add_newdoc('numpy.core.multiarray', 'newbuffer',
|
Chris@87
|
1848 """
|
Chris@87
|
1849 newbuffer(size)
|
Chris@87
|
1850
|
Chris@87
|
1851 Return a new uninitialized buffer object.
|
Chris@87
|
1852
|
Chris@87
|
1853 Parameters
|
Chris@87
|
1854 ----------
|
Chris@87
|
1855 size : int
|
Chris@87
|
1856 Size in bytes of returned buffer object.
|
Chris@87
|
1857
|
Chris@87
|
1858 Returns
|
Chris@87
|
1859 -------
|
Chris@87
|
1860 newbuffer : buffer object
|
Chris@87
|
1861 Returned, uninitialized buffer object of `size` bytes.
|
Chris@87
|
1862
|
Chris@87
|
1863 """)
|
Chris@87
|
1864
|
Chris@87
|
1865 add_newdoc('numpy.core.multiarray', 'getbuffer',
|
Chris@87
|
1866 """
|
Chris@87
|
1867 getbuffer(obj [,offset[, size]])
|
Chris@87
|
1868
|
Chris@87
|
1869 Create a buffer object from the given object referencing a slice of
|
Chris@87
|
1870 length size starting at offset.
|
Chris@87
|
1871
|
Chris@87
|
1872 Default is the entire buffer. A read-write buffer is attempted followed
|
Chris@87
|
1873 by a read-only buffer.
|
Chris@87
|
1874
|
Chris@87
|
1875 Parameters
|
Chris@87
|
1876 ----------
|
Chris@87
|
1877 obj : object
|
Chris@87
|
1878
|
Chris@87
|
1879 offset : int, optional
|
Chris@87
|
1880
|
Chris@87
|
1881 size : int, optional
|
Chris@87
|
1882
|
Chris@87
|
1883 Returns
|
Chris@87
|
1884 -------
|
Chris@87
|
1885 buffer_obj : buffer
|
Chris@87
|
1886
|
Chris@87
|
1887 Examples
|
Chris@87
|
1888 --------
|
Chris@87
|
1889 >>> buf = np.getbuffer(np.ones(5), 1, 3)
|
Chris@87
|
1890 >>> len(buf)
|
Chris@87
|
1891 3
|
Chris@87
|
1892 >>> buf[0]
|
Chris@87
|
1893 '\\x00'
|
Chris@87
|
1894 >>> buf
|
Chris@87
|
1895 <read-write buffer for 0x8af1e70, size 3, offset 1 at 0x8ba4ec0>
|
Chris@87
|
1896
|
Chris@87
|
1897 """)
|
Chris@87
|
1898
|
Chris@87
|
1899 add_newdoc('numpy.core', 'dot',
|
Chris@87
|
1900 """
|
Chris@87
|
1901 dot(a, b, out=None)
|
Chris@87
|
1902
|
Chris@87
|
1903 Dot product of two arrays.
|
Chris@87
|
1904
|
Chris@87
|
1905 For 2-D arrays it is equivalent to matrix multiplication, and for 1-D
|
Chris@87
|
1906 arrays to inner product of vectors (without complex conjugation). For
|
Chris@87
|
1907 N dimensions it is a sum product over the last axis of `a` and
|
Chris@87
|
1908 the second-to-last of `b`::
|
Chris@87
|
1909
|
Chris@87
|
1910 dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
|
Chris@87
|
1911
|
Chris@87
|
1912 Parameters
|
Chris@87
|
1913 ----------
|
Chris@87
|
1914 a : array_like
|
Chris@87
|
1915 First argument.
|
Chris@87
|
1916 b : array_like
|
Chris@87
|
1917 Second argument.
|
Chris@87
|
1918 out : ndarray, optional
|
Chris@87
|
1919 Output argument. This must have the exact kind that would be returned
|
Chris@87
|
1920 if it was not used. In particular, it must have the right type, must be
|
Chris@87
|
1921 C-contiguous, and its dtype must be the dtype that would be returned
|
Chris@87
|
1922 for `dot(a,b)`. This is a performance feature. Therefore, if these
|
Chris@87
|
1923 conditions are not met, an exception is raised, instead of attempting
|
Chris@87
|
1924 to be flexible.
|
Chris@87
|
1925
|
Chris@87
|
1926 Returns
|
Chris@87
|
1927 -------
|
Chris@87
|
1928 output : ndarray
|
Chris@87
|
1929 Returns the dot product of `a` and `b`. If `a` and `b` are both
|
Chris@87
|
1930 scalars or both 1-D arrays then a scalar is returned; otherwise
|
Chris@87
|
1931 an array is returned.
|
Chris@87
|
1932 If `out` is given, then it is returned.
|
Chris@87
|
1933
|
Chris@87
|
1934 Raises
|
Chris@87
|
1935 ------
|
Chris@87
|
1936 ValueError
|
Chris@87
|
1937 If the last dimension of `a` is not the same size as
|
Chris@87
|
1938 the second-to-last dimension of `b`.
|
Chris@87
|
1939
|
Chris@87
|
1940 See Also
|
Chris@87
|
1941 --------
|
Chris@87
|
1942 vdot : Complex-conjugating dot product.
|
Chris@87
|
1943 tensordot : Sum products over arbitrary axes.
|
Chris@87
|
1944 einsum : Einstein summation convention.
|
Chris@87
|
1945
|
Chris@87
|
1946 Examples
|
Chris@87
|
1947 --------
|
Chris@87
|
1948 >>> np.dot(3, 4)
|
Chris@87
|
1949 12
|
Chris@87
|
1950
|
Chris@87
|
1951 Neither argument is complex-conjugated:
|
Chris@87
|
1952
|
Chris@87
|
1953 >>> np.dot([2j, 3j], [2j, 3j])
|
Chris@87
|
1954 (-13+0j)
|
Chris@87
|
1955
|
Chris@87
|
1956 For 2-D arrays it's the matrix product:
|
Chris@87
|
1957
|
Chris@87
|
1958 >>> a = [[1, 0], [0, 1]]
|
Chris@87
|
1959 >>> b = [[4, 1], [2, 2]]
|
Chris@87
|
1960 >>> np.dot(a, b)
|
Chris@87
|
1961 array([[4, 1],
|
Chris@87
|
1962 [2, 2]])
|
Chris@87
|
1963
|
Chris@87
|
1964 >>> a = np.arange(3*4*5*6).reshape((3,4,5,6))
|
Chris@87
|
1965 >>> b = np.arange(3*4*5*6)[::-1].reshape((5,4,6,3))
|
Chris@87
|
1966 >>> np.dot(a, b)[2,3,2,1,2,2]
|
Chris@87
|
1967 499128
|
Chris@87
|
1968 >>> sum(a[2,3,2,:] * b[1,2,:,2])
|
Chris@87
|
1969 499128
|
Chris@87
|
1970
|
Chris@87
|
1971 """)
|
Chris@87
|
1972
|
Chris@87
|
1973 add_newdoc('numpy.core', 'einsum',
|
Chris@87
|
1974 """
|
Chris@87
|
1975 einsum(subscripts, *operands, out=None, dtype=None, order='K', casting='safe')
|
Chris@87
|
1976
|
Chris@87
|
1977 Evaluates the Einstein summation convention on the operands.
|
Chris@87
|
1978
|
Chris@87
|
1979 Using the Einstein summation convention, many common multi-dimensional
|
Chris@87
|
1980 array operations can be represented in a simple fashion. This function
|
Chris@87
|
1981 provides a way compute such summations. The best way to understand this
|
Chris@87
|
1982 function is to try the examples below, which show how many common NumPy
|
Chris@87
|
1983 functions can be implemented as calls to `einsum`.
|
Chris@87
|
1984
|
Chris@87
|
1985 Parameters
|
Chris@87
|
1986 ----------
|
Chris@87
|
1987 subscripts : str
|
Chris@87
|
1988 Specifies the subscripts for summation.
|
Chris@87
|
1989 operands : list of array_like
|
Chris@87
|
1990 These are the arrays for the operation.
|
Chris@87
|
1991 out : ndarray, optional
|
Chris@87
|
1992 If provided, the calculation is done into this array.
|
Chris@87
|
1993 dtype : data-type, optional
|
Chris@87
|
1994 If provided, forces the calculation to use the data type specified.
|
Chris@87
|
1995 Note that you may have to also give a more liberal `casting`
|
Chris@87
|
1996 parameter to allow the conversions.
|
Chris@87
|
1997 order : {'C', 'F', 'A', 'K'}, optional
|
Chris@87
|
1998 Controls the memory layout of the output. 'C' means it should
|
Chris@87
|
1999 be C contiguous. 'F' means it should be Fortran contiguous,
|
Chris@87
|
2000 'A' means it should be 'F' if the inputs are all 'F', 'C' otherwise.
|
Chris@87
|
2001 'K' means it should be as close to the layout as the inputs as
|
Chris@87
|
2002 is possible, including arbitrarily permuted axes.
|
Chris@87
|
2003 Default is 'K'.
|
Chris@87
|
2004 casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
|
Chris@87
|
2005 Controls what kind of data casting may occur. Setting this to
|
Chris@87
|
2006 'unsafe' is not recommended, as it can adversely affect accumulations.
|
Chris@87
|
2007
|
Chris@87
|
2008 * 'no' means the data types should not be cast at all.
|
Chris@87
|
2009 * 'equiv' means only byte-order changes are allowed.
|
Chris@87
|
2010 * 'safe' means only casts which can preserve values are allowed.
|
Chris@87
|
2011 * 'same_kind' means only safe casts or casts within a kind,
|
Chris@87
|
2012 like float64 to float32, are allowed.
|
Chris@87
|
2013 * 'unsafe' means any data conversions may be done.
|
Chris@87
|
2014
|
Chris@87
|
2015 Returns
|
Chris@87
|
2016 -------
|
Chris@87
|
2017 output : ndarray
|
Chris@87
|
2018 The calculation based on the Einstein summation convention.
|
Chris@87
|
2019
|
Chris@87
|
2020 See Also
|
Chris@87
|
2021 --------
|
Chris@87
|
2022 dot, inner, outer, tensordot
|
Chris@87
|
2023
|
Chris@87
|
2024 Notes
|
Chris@87
|
2025 -----
|
Chris@87
|
2026 .. versionadded:: 1.6.0
|
Chris@87
|
2027
|
Chris@87
|
2028 The subscripts string is a comma-separated list of subscript labels,
|
Chris@87
|
2029 where each label refers to a dimension of the corresponding operand.
|
Chris@87
|
2030 Repeated subscripts labels in one operand take the diagonal. For example,
|
Chris@87
|
2031 ``np.einsum('ii', a)`` is equivalent to ``np.trace(a)``.
|
Chris@87
|
2032
|
Chris@87
|
2033 Whenever a label is repeated, it is summed, so ``np.einsum('i,i', a, b)``
|
Chris@87
|
2034 is equivalent to ``np.inner(a,b)``. If a label appears only once,
|
Chris@87
|
2035 it is not summed, so ``np.einsum('i', a)`` produces a view of ``a``
|
Chris@87
|
2036 with no changes.
|
Chris@87
|
2037
|
Chris@87
|
2038 The order of labels in the output is by default alphabetical. This
|
Chris@87
|
2039 means that ``np.einsum('ij', a)`` doesn't affect a 2D array, while
|
Chris@87
|
2040 ``np.einsum('ji', a)`` takes its transpose.
|
Chris@87
|
2041
|
Chris@87
|
2042 The output can be controlled by specifying output subscript labels
|
Chris@87
|
2043 as well. This specifies the label order, and allows summing to
|
Chris@87
|
2044 be disallowed or forced when desired. The call ``np.einsum('i->', a)``
|
Chris@87
|
2045 is like ``np.sum(a, axis=-1)``, and ``np.einsum('ii->i', a)``
|
Chris@87
|
2046 is like ``np.diag(a)``. The difference is that `einsum` does not
|
Chris@87
|
2047 allow broadcasting by default.
|
Chris@87
|
2048
|
Chris@87
|
2049 To enable and control broadcasting, use an ellipsis. Default
|
Chris@87
|
2050 NumPy-style broadcasting is done by adding an ellipsis
|
Chris@87
|
2051 to the left of each term, like ``np.einsum('...ii->...i', a)``.
|
Chris@87
|
2052 To take the trace along the first and last axes,
|
Chris@87
|
2053 you can do ``np.einsum('i...i', a)``, or to do a matrix-matrix
|
Chris@87
|
2054 product with the left-most indices instead of rightmost, you can do
|
Chris@87
|
2055 ``np.einsum('ij...,jk...->ik...', a, b)``.
|
Chris@87
|
2056
|
Chris@87
|
2057 When there is only one operand, no axes are summed, and no output
|
Chris@87
|
2058 parameter is provided, a view into the operand is returned instead
|
Chris@87
|
2059 of a new array. Thus, taking the diagonal as ``np.einsum('ii->i', a)``
|
Chris@87
|
2060 produces a view.
|
Chris@87
|
2061
|
Chris@87
|
2062 An alternative way to provide the subscripts and operands is as
|
Chris@87
|
2063 ``einsum(op0, sublist0, op1, sublist1, ..., [sublistout])``. The examples
|
Chris@87
|
2064 below have corresponding `einsum` calls with the two parameter methods.
|
Chris@87
|
2065
|
Chris@87
|
2066 Examples
|
Chris@87
|
2067 --------
|
Chris@87
|
2068 >>> a = np.arange(25).reshape(5,5)
|
Chris@87
|
2069 >>> b = np.arange(5)
|
Chris@87
|
2070 >>> c = np.arange(6).reshape(2,3)
|
Chris@87
|
2071
|
Chris@87
|
2072 >>> np.einsum('ii', a)
|
Chris@87
|
2073 60
|
Chris@87
|
2074 >>> np.einsum(a, [0,0])
|
Chris@87
|
2075 60
|
Chris@87
|
2076 >>> np.trace(a)
|
Chris@87
|
2077 60
|
Chris@87
|
2078
|
Chris@87
|
2079 >>> np.einsum('ii->i', a)
|
Chris@87
|
2080 array([ 0, 6, 12, 18, 24])
|
Chris@87
|
2081 >>> np.einsum(a, [0,0], [0])
|
Chris@87
|
2082 array([ 0, 6, 12, 18, 24])
|
Chris@87
|
2083 >>> np.diag(a)
|
Chris@87
|
2084 array([ 0, 6, 12, 18, 24])
|
Chris@87
|
2085
|
Chris@87
|
2086 >>> np.einsum('ij,j', a, b)
|
Chris@87
|
2087 array([ 30, 80, 130, 180, 230])
|
Chris@87
|
2088 >>> np.einsum(a, [0,1], b, [1])
|
Chris@87
|
2089 array([ 30, 80, 130, 180, 230])
|
Chris@87
|
2090 >>> np.dot(a, b)
|
Chris@87
|
2091 array([ 30, 80, 130, 180, 230])
|
Chris@87
|
2092 >>> np.einsum('...j,j', a, b)
|
Chris@87
|
2093 array([ 30, 80, 130, 180, 230])
|
Chris@87
|
2094
|
Chris@87
|
2095 >>> np.einsum('ji', c)
|
Chris@87
|
2096 array([[0, 3],
|
Chris@87
|
2097 [1, 4],
|
Chris@87
|
2098 [2, 5]])
|
Chris@87
|
2099 >>> np.einsum(c, [1,0])
|
Chris@87
|
2100 array([[0, 3],
|
Chris@87
|
2101 [1, 4],
|
Chris@87
|
2102 [2, 5]])
|
Chris@87
|
2103 >>> c.T
|
Chris@87
|
2104 array([[0, 3],
|
Chris@87
|
2105 [1, 4],
|
Chris@87
|
2106 [2, 5]])
|
Chris@87
|
2107
|
Chris@87
|
2108 >>> np.einsum('..., ...', 3, c)
|
Chris@87
|
2109 array([[ 0, 3, 6],
|
Chris@87
|
2110 [ 9, 12, 15]])
|
Chris@87
|
2111 >>> np.einsum(3, [Ellipsis], c, [Ellipsis])
|
Chris@87
|
2112 array([[ 0, 3, 6],
|
Chris@87
|
2113 [ 9, 12, 15]])
|
Chris@87
|
2114 >>> np.multiply(3, c)
|
Chris@87
|
2115 array([[ 0, 3, 6],
|
Chris@87
|
2116 [ 9, 12, 15]])
|
Chris@87
|
2117
|
Chris@87
|
2118 >>> np.einsum('i,i', b, b)
|
Chris@87
|
2119 30
|
Chris@87
|
2120 >>> np.einsum(b, [0], b, [0])
|
Chris@87
|
2121 30
|
Chris@87
|
2122 >>> np.inner(b,b)
|
Chris@87
|
2123 30
|
Chris@87
|
2124
|
Chris@87
|
2125 >>> np.einsum('i,j', np.arange(2)+1, b)
|
Chris@87
|
2126 array([[0, 1, 2, 3, 4],
|
Chris@87
|
2127 [0, 2, 4, 6, 8]])
|
Chris@87
|
2128 >>> np.einsum(np.arange(2)+1, [0], b, [1])
|
Chris@87
|
2129 array([[0, 1, 2, 3, 4],
|
Chris@87
|
2130 [0, 2, 4, 6, 8]])
|
Chris@87
|
2131 >>> np.outer(np.arange(2)+1, b)
|
Chris@87
|
2132 array([[0, 1, 2, 3, 4],
|
Chris@87
|
2133 [0, 2, 4, 6, 8]])
|
Chris@87
|
2134
|
Chris@87
|
2135 >>> np.einsum('i...->...', a)
|
Chris@87
|
2136 array([50, 55, 60, 65, 70])
|
Chris@87
|
2137 >>> np.einsum(a, [0,Ellipsis], [Ellipsis])
|
Chris@87
|
2138 array([50, 55, 60, 65, 70])
|
Chris@87
|
2139 >>> np.sum(a, axis=0)
|
Chris@87
|
2140 array([50, 55, 60, 65, 70])
|
Chris@87
|
2141
|
Chris@87
|
2142 >>> a = np.arange(60.).reshape(3,4,5)
|
Chris@87
|
2143 >>> b = np.arange(24.).reshape(4,3,2)
|
Chris@87
|
2144 >>> np.einsum('ijk,jil->kl', a, b)
|
Chris@87
|
2145 array([[ 4400., 4730.],
|
Chris@87
|
2146 [ 4532., 4874.],
|
Chris@87
|
2147 [ 4664., 5018.],
|
Chris@87
|
2148 [ 4796., 5162.],
|
Chris@87
|
2149 [ 4928., 5306.]])
|
Chris@87
|
2150 >>> np.einsum(a, [0,1,2], b, [1,0,3], [2,3])
|
Chris@87
|
2151 array([[ 4400., 4730.],
|
Chris@87
|
2152 [ 4532., 4874.],
|
Chris@87
|
2153 [ 4664., 5018.],
|
Chris@87
|
2154 [ 4796., 5162.],
|
Chris@87
|
2155 [ 4928., 5306.]])
|
Chris@87
|
2156 >>> np.tensordot(a,b, axes=([1,0],[0,1]))
|
Chris@87
|
2157 array([[ 4400., 4730.],
|
Chris@87
|
2158 [ 4532., 4874.],
|
Chris@87
|
2159 [ 4664., 5018.],
|
Chris@87
|
2160 [ 4796., 5162.],
|
Chris@87
|
2161 [ 4928., 5306.]])
|
Chris@87
|
2162
|
Chris@87
|
2163 >>> a = np.arange(6).reshape((3,2))
|
Chris@87
|
2164 >>> b = np.arange(12).reshape((4,3))
|
Chris@87
|
2165 >>> np.einsum('ki,jk->ij', a, b)
|
Chris@87
|
2166 array([[10, 28, 46, 64],
|
Chris@87
|
2167 [13, 40, 67, 94]])
|
Chris@87
|
2168 >>> np.einsum('ki,...k->i...', a, b)
|
Chris@87
|
2169 array([[10, 28, 46, 64],
|
Chris@87
|
2170 [13, 40, 67, 94]])
|
Chris@87
|
2171 >>> np.einsum('k...,jk', a, b)
|
Chris@87
|
2172 array([[10, 28, 46, 64],
|
Chris@87
|
2173 [13, 40, 67, 94]])
|
Chris@87
|
2174
|
Chris@87
|
2175 """)
|
Chris@87
|
2176
|
Chris@87
|
2177 add_newdoc('numpy.core', 'alterdot',
|
Chris@87
|
2178 """
|
Chris@87
|
2179 Change `dot`, `vdot`, and `inner` to use accelerated BLAS functions.
|
Chris@87
|
2180
|
Chris@87
|
2181 Typically, as a user of Numpy, you do not explicitly call this function. If
|
Chris@87
|
2182 Numpy is built with an accelerated BLAS, this function is automatically
|
Chris@87
|
2183 called when Numpy is imported.
|
Chris@87
|
2184
|
Chris@87
|
2185 When Numpy is built with an accelerated BLAS like ATLAS, these functions
|
Chris@87
|
2186 are replaced to make use of the faster implementations. The faster
|
Chris@87
|
2187 implementations only affect float32, float64, complex64, and complex128
|
Chris@87
|
2188 arrays. Furthermore, the BLAS API only includes matrix-matrix,
|
Chris@87
|
2189 matrix-vector, and vector-vector products. Products of arrays with larger
|
Chris@87
|
2190 dimensionalities use the built in functions and are not accelerated.
|
Chris@87
|
2191
|
Chris@87
|
2192 See Also
|
Chris@87
|
2193 --------
|
Chris@87
|
2194 restoredot : `restoredot` undoes the effects of `alterdot`.
|
Chris@87
|
2195
|
Chris@87
|
2196 """)
|
Chris@87
|
2197
|
Chris@87
|
2198 add_newdoc('numpy.core', 'restoredot',
|
Chris@87
|
2199 """
|
Chris@87
|
2200 Restore `dot`, `vdot`, and `innerproduct` to the default non-BLAS
|
Chris@87
|
2201 implementations.
|
Chris@87
|
2202
|
Chris@87
|
2203 Typically, the user will only need to call this when troubleshooting and
|
Chris@87
|
2204 installation problem, reproducing the conditions of a build without an
|
Chris@87
|
2205 accelerated BLAS, or when being very careful about benchmarking linear
|
Chris@87
|
2206 algebra operations.
|
Chris@87
|
2207
|
Chris@87
|
2208 See Also
|
Chris@87
|
2209 --------
|
Chris@87
|
2210 alterdot : `restoredot` undoes the effects of `alterdot`.
|
Chris@87
|
2211
|
Chris@87
|
2212 """)
|
Chris@87
|
2213
|
Chris@87
|
2214 add_newdoc('numpy.core', 'vdot',
|
Chris@87
|
2215 """
|
Chris@87
|
2216 vdot(a, b)
|
Chris@87
|
2217
|
Chris@87
|
2218 Return the dot product of two vectors.
|
Chris@87
|
2219
|
Chris@87
|
2220 The vdot(`a`, `b`) function handles complex numbers differently than
|
Chris@87
|
2221 dot(`a`, `b`). If the first argument is complex the complex conjugate
|
Chris@87
|
2222 of the first argument is used for the calculation of the dot product.
|
Chris@87
|
2223
|
Chris@87
|
2224 Note that `vdot` handles multidimensional arrays differently than `dot`:
|
Chris@87
|
2225 it does *not* perform a matrix product, but flattens input arguments
|
Chris@87
|
2226 to 1-D vectors first. Consequently, it should only be used for vectors.
|
Chris@87
|
2227
|
Chris@87
|
2228 Parameters
|
Chris@87
|
2229 ----------
|
Chris@87
|
2230 a : array_like
|
Chris@87
|
2231 If `a` is complex the complex conjugate is taken before calculation
|
Chris@87
|
2232 of the dot product.
|
Chris@87
|
2233 b : array_like
|
Chris@87
|
2234 Second argument to the dot product.
|
Chris@87
|
2235
|
Chris@87
|
2236 Returns
|
Chris@87
|
2237 -------
|
Chris@87
|
2238 output : ndarray
|
Chris@87
|
2239 Dot product of `a` and `b`. Can be an int, float, or
|
Chris@87
|
2240 complex depending on the types of `a` and `b`.
|
Chris@87
|
2241
|
Chris@87
|
2242 See Also
|
Chris@87
|
2243 --------
|
Chris@87
|
2244 dot : Return the dot product without using the complex conjugate of the
|
Chris@87
|
2245 first argument.
|
Chris@87
|
2246
|
Chris@87
|
2247 Examples
|
Chris@87
|
2248 --------
|
Chris@87
|
2249 >>> a = np.array([1+2j,3+4j])
|
Chris@87
|
2250 >>> b = np.array([5+6j,7+8j])
|
Chris@87
|
2251 >>> np.vdot(a, b)
|
Chris@87
|
2252 (70-8j)
|
Chris@87
|
2253 >>> np.vdot(b, a)
|
Chris@87
|
2254 (70+8j)
|
Chris@87
|
2255
|
Chris@87
|
2256 Note that higher-dimensional arrays are flattened!
|
Chris@87
|
2257
|
Chris@87
|
2258 >>> a = np.array([[1, 4], [5, 6]])
|
Chris@87
|
2259 >>> b = np.array([[4, 1], [2, 2]])
|
Chris@87
|
2260 >>> np.vdot(a, b)
|
Chris@87
|
2261 30
|
Chris@87
|
2262 >>> np.vdot(b, a)
|
Chris@87
|
2263 30
|
Chris@87
|
2264 >>> 1*4 + 4*1 + 5*2 + 6*2
|
Chris@87
|
2265 30
|
Chris@87
|
2266
|
Chris@87
|
2267 """)
|
Chris@87
|
2268
|
Chris@87
|
2269
|
Chris@87
|
2270 ##############################################################################
|
Chris@87
|
2271 #
|
Chris@87
|
2272 # Documentation for ndarray attributes and methods
|
Chris@87
|
2273 #
|
Chris@87
|
2274 ##############################################################################
|
Chris@87
|
2275
|
Chris@87
|
2276
|
Chris@87
|
2277 ##############################################################################
|
Chris@87
|
2278 #
|
Chris@87
|
2279 # ndarray object
|
Chris@87
|
2280 #
|
Chris@87
|
2281 ##############################################################################
|
Chris@87
|
2282
|
Chris@87
|
2283
|
Chris@87
|
2284 add_newdoc('numpy.core.multiarray', 'ndarray',
|
Chris@87
|
2285 """
|
Chris@87
|
2286 ndarray(shape, dtype=float, buffer=None, offset=0,
|
Chris@87
|
2287 strides=None, order=None)
|
Chris@87
|
2288
|
Chris@87
|
2289 An array object represents a multidimensional, homogeneous array
|
Chris@87
|
2290 of fixed-size items. An associated data-type object describes the
|
Chris@87
|
2291 format of each element in the array (its byte-order, how many bytes it
|
Chris@87
|
2292 occupies in memory, whether it is an integer, a floating point number,
|
Chris@87
|
2293 or something else, etc.)
|
Chris@87
|
2294
|
Chris@87
|
2295 Arrays should be constructed using `array`, `zeros` or `empty` (refer
|
Chris@87
|
2296 to the See Also section below). The parameters given here refer to
|
Chris@87
|
2297 a low-level method (`ndarray(...)`) for instantiating an array.
|
Chris@87
|
2298
|
Chris@87
|
2299 For more information, refer to the `numpy` module and examine the
|
Chris@87
|
2300 the methods and attributes of an array.
|
Chris@87
|
2301
|
Chris@87
|
2302 Parameters
|
Chris@87
|
2303 ----------
|
Chris@87
|
2304 (for the __new__ method; see Notes below)
|
Chris@87
|
2305
|
Chris@87
|
2306 shape : tuple of ints
|
Chris@87
|
2307 Shape of created array.
|
Chris@87
|
2308 dtype : data-type, optional
|
Chris@87
|
2309 Any object that can be interpreted as a numpy data type.
|
Chris@87
|
2310 buffer : object exposing buffer interface, optional
|
Chris@87
|
2311 Used to fill the array with data.
|
Chris@87
|
2312 offset : int, optional
|
Chris@87
|
2313 Offset of array data in buffer.
|
Chris@87
|
2314 strides : tuple of ints, optional
|
Chris@87
|
2315 Strides of data in memory.
|
Chris@87
|
2316 order : {'C', 'F'}, optional
|
Chris@87
|
2317 Row-major or column-major order.
|
Chris@87
|
2318
|
Chris@87
|
2319 Attributes
|
Chris@87
|
2320 ----------
|
Chris@87
|
2321 T : ndarray
|
Chris@87
|
2322 Transpose of the array.
|
Chris@87
|
2323 data : buffer
|
Chris@87
|
2324 The array's elements, in memory.
|
Chris@87
|
2325 dtype : dtype object
|
Chris@87
|
2326 Describes the format of the elements in the array.
|
Chris@87
|
2327 flags : dict
|
Chris@87
|
2328 Dictionary containing information related to memory use, e.g.,
|
Chris@87
|
2329 'C_CONTIGUOUS', 'OWNDATA', 'WRITEABLE', etc.
|
Chris@87
|
2330 flat : numpy.flatiter object
|
Chris@87
|
2331 Flattened version of the array as an iterator. The iterator
|
Chris@87
|
2332 allows assignments, e.g., ``x.flat = 3`` (See `ndarray.flat` for
|
Chris@87
|
2333 assignment examples; TODO).
|
Chris@87
|
2334 imag : ndarray
|
Chris@87
|
2335 Imaginary part of the array.
|
Chris@87
|
2336 real : ndarray
|
Chris@87
|
2337 Real part of the array.
|
Chris@87
|
2338 size : int
|
Chris@87
|
2339 Number of elements in the array.
|
Chris@87
|
2340 itemsize : int
|
Chris@87
|
2341 The memory use of each array element in bytes.
|
Chris@87
|
2342 nbytes : int
|
Chris@87
|
2343 The total number of bytes required to store the array data,
|
Chris@87
|
2344 i.e., ``itemsize * size``.
|
Chris@87
|
2345 ndim : int
|
Chris@87
|
2346 The array's number of dimensions.
|
Chris@87
|
2347 shape : tuple of ints
|
Chris@87
|
2348 Shape of the array.
|
Chris@87
|
2349 strides : tuple of ints
|
Chris@87
|
2350 The step-size required to move from one element to the next in
|
Chris@87
|
2351 memory. For example, a contiguous ``(3, 4)`` array of type
|
Chris@87
|
2352 ``int16`` in C-order has strides ``(8, 2)``. This implies that
|
Chris@87
|
2353 to move from element to element in memory requires jumps of 2 bytes.
|
Chris@87
|
2354 To move from row-to-row, one needs to jump 8 bytes at a time
|
Chris@87
|
2355 (``2 * 4``).
|
Chris@87
|
2356 ctypes : ctypes object
|
Chris@87
|
2357 Class containing properties of the array needed for interaction
|
Chris@87
|
2358 with ctypes.
|
Chris@87
|
2359 base : ndarray
|
Chris@87
|
2360 If the array is a view into another array, that array is its `base`
|
Chris@87
|
2361 (unless that array is also a view). The `base` array is where the
|
Chris@87
|
2362 array data is actually stored.
|
Chris@87
|
2363
|
Chris@87
|
2364 See Also
|
Chris@87
|
2365 --------
|
Chris@87
|
2366 array : Construct an array.
|
Chris@87
|
2367 zeros : Create an array, each element of which is zero.
|
Chris@87
|
2368 empty : Create an array, but leave its allocated memory unchanged (i.e.,
|
Chris@87
|
2369 it contains "garbage").
|
Chris@87
|
2370 dtype : Create a data-type.
|
Chris@87
|
2371
|
Chris@87
|
2372 Notes
|
Chris@87
|
2373 -----
|
Chris@87
|
2374 There are two modes of creating an array using ``__new__``:
|
Chris@87
|
2375
|
Chris@87
|
2376 1. If `buffer` is None, then only `shape`, `dtype`, and `order`
|
Chris@87
|
2377 are used.
|
Chris@87
|
2378 2. If `buffer` is an object exposing the buffer interface, then
|
Chris@87
|
2379 all keywords are interpreted.
|
Chris@87
|
2380
|
Chris@87
|
2381 No ``__init__`` method is needed because the array is fully initialized
|
Chris@87
|
2382 after the ``__new__`` method.
|
Chris@87
|
2383
|
Chris@87
|
2384 Examples
|
Chris@87
|
2385 --------
|
Chris@87
|
2386 These examples illustrate the low-level `ndarray` constructor. Refer
|
Chris@87
|
2387 to the `See Also` section above for easier ways of constructing an
|
Chris@87
|
2388 ndarray.
|
Chris@87
|
2389
|
Chris@87
|
2390 First mode, `buffer` is None:
|
Chris@87
|
2391
|
Chris@87
|
2392 >>> np.ndarray(shape=(2,2), dtype=float, order='F')
|
Chris@87
|
2393 array([[ -1.13698227e+002, 4.25087011e-303],
|
Chris@87
|
2394 [ 2.88528414e-306, 3.27025015e-309]]) #random
|
Chris@87
|
2395
|
Chris@87
|
2396 Second mode:
|
Chris@87
|
2397
|
Chris@87
|
2398 >>> np.ndarray((2,), buffer=np.array([1,2,3]),
|
Chris@87
|
2399 ... offset=np.int_().itemsize,
|
Chris@87
|
2400 ... dtype=int) # offset = 1*itemsize, i.e. skip first element
|
Chris@87
|
2401 array([2, 3])
|
Chris@87
|
2402
|
Chris@87
|
2403 """)
|
Chris@87
|
2404
|
Chris@87
|
2405
|
Chris@87
|
2406 ##############################################################################
|
Chris@87
|
2407 #
|
Chris@87
|
2408 # ndarray attributes
|
Chris@87
|
2409 #
|
Chris@87
|
2410 ##############################################################################
|
Chris@87
|
2411
|
Chris@87
|
2412
|
Chris@87
|
2413 add_newdoc('numpy.core.multiarray', 'ndarray', ('__array_interface__',
|
Chris@87
|
2414 """Array protocol: Python side."""))
|
Chris@87
|
2415
|
Chris@87
|
2416
|
Chris@87
|
2417 add_newdoc('numpy.core.multiarray', 'ndarray', ('__array_finalize__',
|
Chris@87
|
2418 """None."""))
|
Chris@87
|
2419
|
Chris@87
|
2420
|
Chris@87
|
2421 add_newdoc('numpy.core.multiarray', 'ndarray', ('__array_priority__',
|
Chris@87
|
2422 """Array priority."""))
|
Chris@87
|
2423
|
Chris@87
|
2424
|
Chris@87
|
2425 add_newdoc('numpy.core.multiarray', 'ndarray', ('__array_struct__',
|
Chris@87
|
2426 """Array protocol: C-struct side."""))
|
Chris@87
|
2427
|
Chris@87
|
2428
|
Chris@87
|
2429 add_newdoc('numpy.core.multiarray', 'ndarray', ('_as_parameter_',
|
Chris@87
|
2430 """Allow the array to be interpreted as a ctypes object by returning the
|
Chris@87
|
2431 data-memory location as an integer
|
Chris@87
|
2432
|
Chris@87
|
2433 """))
|
Chris@87
|
2434
|
Chris@87
|
2435
|
Chris@87
|
2436 add_newdoc('numpy.core.multiarray', 'ndarray', ('base',
|
Chris@87
|
2437 """
|
Chris@87
|
2438 Base object if memory is from some other object.
|
Chris@87
|
2439
|
Chris@87
|
2440 Examples
|
Chris@87
|
2441 --------
|
Chris@87
|
2442 The base of an array that owns its memory is None:
|
Chris@87
|
2443
|
Chris@87
|
2444 >>> x = np.array([1,2,3,4])
|
Chris@87
|
2445 >>> x.base is None
|
Chris@87
|
2446 True
|
Chris@87
|
2447
|
Chris@87
|
2448 Slicing creates a view, whose memory is shared with x:
|
Chris@87
|
2449
|
Chris@87
|
2450 >>> y = x[2:]
|
Chris@87
|
2451 >>> y.base is x
|
Chris@87
|
2452 True
|
Chris@87
|
2453
|
Chris@87
|
2454 """))
|
Chris@87
|
2455
|
Chris@87
|
2456
|
Chris@87
|
2457 add_newdoc('numpy.core.multiarray', 'ndarray', ('ctypes',
|
Chris@87
|
2458 """
|
Chris@87
|
2459 An object to simplify the interaction of the array with the ctypes
|
Chris@87
|
2460 module.
|
Chris@87
|
2461
|
Chris@87
|
2462 This attribute creates an object that makes it easier to use arrays
|
Chris@87
|
2463 when calling shared libraries with the ctypes module. The returned
|
Chris@87
|
2464 object has, among others, data, shape, and strides attributes (see
|
Chris@87
|
2465 Notes below) which themselves return ctypes objects that can be used
|
Chris@87
|
2466 as arguments to a shared library.
|
Chris@87
|
2467
|
Chris@87
|
2468 Parameters
|
Chris@87
|
2469 ----------
|
Chris@87
|
2470 None
|
Chris@87
|
2471
|
Chris@87
|
2472 Returns
|
Chris@87
|
2473 -------
|
Chris@87
|
2474 c : Python object
|
Chris@87
|
2475 Possessing attributes data, shape, strides, etc.
|
Chris@87
|
2476
|
Chris@87
|
2477 See Also
|
Chris@87
|
2478 --------
|
Chris@87
|
2479 numpy.ctypeslib
|
Chris@87
|
2480
|
Chris@87
|
2481 Notes
|
Chris@87
|
2482 -----
|
Chris@87
|
2483 Below are the public attributes of this object which were documented
|
Chris@87
|
2484 in "Guide to NumPy" (we have omitted undocumented public attributes,
|
Chris@87
|
2485 as well as documented private attributes):
|
Chris@87
|
2486
|
Chris@87
|
2487 * data: A pointer to the memory area of the array as a Python integer.
|
Chris@87
|
2488 This memory area may contain data that is not aligned, or not in correct
|
Chris@87
|
2489 byte-order. The memory area may not even be writeable. The array
|
Chris@87
|
2490 flags and data-type of this array should be respected when passing this
|
Chris@87
|
2491 attribute to arbitrary C-code to avoid trouble that can include Python
|
Chris@87
|
2492 crashing. User Beware! The value of this attribute is exactly the same
|
Chris@87
|
2493 as self._array_interface_['data'][0].
|
Chris@87
|
2494
|
Chris@87
|
2495 * shape (c_intp*self.ndim): A ctypes array of length self.ndim where
|
Chris@87
|
2496 the basetype is the C-integer corresponding to dtype('p') on this
|
Chris@87
|
2497 platform. This base-type could be c_int, c_long, or c_longlong
|
Chris@87
|
2498 depending on the platform. The c_intp type is defined accordingly in
|
Chris@87
|
2499 numpy.ctypeslib. The ctypes array contains the shape of the underlying
|
Chris@87
|
2500 array.
|
Chris@87
|
2501
|
Chris@87
|
2502 * strides (c_intp*self.ndim): A ctypes array of length self.ndim where
|
Chris@87
|
2503 the basetype is the same as for the shape attribute. This ctypes array
|
Chris@87
|
2504 contains the strides information from the underlying array. This strides
|
Chris@87
|
2505 information is important for showing how many bytes must be jumped to
|
Chris@87
|
2506 get to the next element in the array.
|
Chris@87
|
2507
|
Chris@87
|
2508 * data_as(obj): Return the data pointer cast to a particular c-types object.
|
Chris@87
|
2509 For example, calling self._as_parameter_ is equivalent to
|
Chris@87
|
2510 self.data_as(ctypes.c_void_p). Perhaps you want to use the data as a
|
Chris@87
|
2511 pointer to a ctypes array of floating-point data:
|
Chris@87
|
2512 self.data_as(ctypes.POINTER(ctypes.c_double)).
|
Chris@87
|
2513
|
Chris@87
|
2514 * shape_as(obj): Return the shape tuple as an array of some other c-types
|
Chris@87
|
2515 type. For example: self.shape_as(ctypes.c_short).
|
Chris@87
|
2516
|
Chris@87
|
2517 * strides_as(obj): Return the strides tuple as an array of some other
|
Chris@87
|
2518 c-types type. For example: self.strides_as(ctypes.c_longlong).
|
Chris@87
|
2519
|
Chris@87
|
2520 Be careful using the ctypes attribute - especially on temporary
|
Chris@87
|
2521 arrays or arrays constructed on the fly. For example, calling
|
Chris@87
|
2522 ``(a+b).ctypes.data_as(ctypes.c_void_p)`` returns a pointer to memory
|
Chris@87
|
2523 that is invalid because the array created as (a+b) is deallocated
|
Chris@87
|
2524 before the next Python statement. You can avoid this problem using
|
Chris@87
|
2525 either ``c=a+b`` or ``ct=(a+b).ctypes``. In the latter case, ct will
|
Chris@87
|
2526 hold a reference to the array until ct is deleted or re-assigned.
|
Chris@87
|
2527
|
Chris@87
|
2528 If the ctypes module is not available, then the ctypes attribute
|
Chris@87
|
2529 of array objects still returns something useful, but ctypes objects
|
Chris@87
|
2530 are not returned and errors may be raised instead. In particular,
|
Chris@87
|
2531 the object will still have the as parameter attribute which will
|
Chris@87
|
2532 return an integer equal to the data attribute.
|
Chris@87
|
2533
|
Chris@87
|
2534 Examples
|
Chris@87
|
2535 --------
|
Chris@87
|
2536 >>> import ctypes
|
Chris@87
|
2537 >>> x
|
Chris@87
|
2538 array([[0, 1],
|
Chris@87
|
2539 [2, 3]])
|
Chris@87
|
2540 >>> x.ctypes.data
|
Chris@87
|
2541 30439712
|
Chris@87
|
2542 >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_long))
|
Chris@87
|
2543 <ctypes.LP_c_long object at 0x01F01300>
|
Chris@87
|
2544 >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_long)).contents
|
Chris@87
|
2545 c_long(0)
|
Chris@87
|
2546 >>> x.ctypes.data_as(ctypes.POINTER(ctypes.c_longlong)).contents
|
Chris@87
|
2547 c_longlong(4294967296L)
|
Chris@87
|
2548 >>> x.ctypes.shape
|
Chris@87
|
2549 <numpy.core._internal.c_long_Array_2 object at 0x01FFD580>
|
Chris@87
|
2550 >>> x.ctypes.shape_as(ctypes.c_long)
|
Chris@87
|
2551 <numpy.core._internal.c_long_Array_2 object at 0x01FCE620>
|
Chris@87
|
2552 >>> x.ctypes.strides
|
Chris@87
|
2553 <numpy.core._internal.c_long_Array_2 object at 0x01FCE620>
|
Chris@87
|
2554 >>> x.ctypes.strides_as(ctypes.c_longlong)
|
Chris@87
|
2555 <numpy.core._internal.c_longlong_Array_2 object at 0x01F01300>
|
Chris@87
|
2556
|
Chris@87
|
2557 """))
|
Chris@87
|
2558
|
Chris@87
|
2559
|
Chris@87
|
2560 add_newdoc('numpy.core.multiarray', 'ndarray', ('data',
|
Chris@87
|
2561 """Python buffer object pointing to the start of the array's data."""))
|
Chris@87
|
2562
|
Chris@87
|
2563
|
Chris@87
|
2564 add_newdoc('numpy.core.multiarray', 'ndarray', ('dtype',
|
Chris@87
|
2565 """
|
Chris@87
|
2566 Data-type of the array's elements.
|
Chris@87
|
2567
|
Chris@87
|
2568 Parameters
|
Chris@87
|
2569 ----------
|
Chris@87
|
2570 None
|
Chris@87
|
2571
|
Chris@87
|
2572 Returns
|
Chris@87
|
2573 -------
|
Chris@87
|
2574 d : numpy dtype object
|
Chris@87
|
2575
|
Chris@87
|
2576 See Also
|
Chris@87
|
2577 --------
|
Chris@87
|
2578 numpy.dtype
|
Chris@87
|
2579
|
Chris@87
|
2580 Examples
|
Chris@87
|
2581 --------
|
Chris@87
|
2582 >>> x
|
Chris@87
|
2583 array([[0, 1],
|
Chris@87
|
2584 [2, 3]])
|
Chris@87
|
2585 >>> x.dtype
|
Chris@87
|
2586 dtype('int32')
|
Chris@87
|
2587 >>> type(x.dtype)
|
Chris@87
|
2588 <type 'numpy.dtype'>
|
Chris@87
|
2589
|
Chris@87
|
2590 """))
|
Chris@87
|
2591
|
Chris@87
|
2592
|
Chris@87
|
2593 add_newdoc('numpy.core.multiarray', 'ndarray', ('imag',
|
Chris@87
|
2594 """
|
Chris@87
|
2595 The imaginary part of the array.
|
Chris@87
|
2596
|
Chris@87
|
2597 Examples
|
Chris@87
|
2598 --------
|
Chris@87
|
2599 >>> x = np.sqrt([1+0j, 0+1j])
|
Chris@87
|
2600 >>> x.imag
|
Chris@87
|
2601 array([ 0. , 0.70710678])
|
Chris@87
|
2602 >>> x.imag.dtype
|
Chris@87
|
2603 dtype('float64')
|
Chris@87
|
2604
|
Chris@87
|
2605 """))
|
Chris@87
|
2606
|
Chris@87
|
2607
|
Chris@87
|
2608 add_newdoc('numpy.core.multiarray', 'ndarray', ('itemsize',
|
Chris@87
|
2609 """
|
Chris@87
|
2610 Length of one array element in bytes.
|
Chris@87
|
2611
|
Chris@87
|
2612 Examples
|
Chris@87
|
2613 --------
|
Chris@87
|
2614 >>> x = np.array([1,2,3], dtype=np.float64)
|
Chris@87
|
2615 >>> x.itemsize
|
Chris@87
|
2616 8
|
Chris@87
|
2617 >>> x = np.array([1,2,3], dtype=np.complex128)
|
Chris@87
|
2618 >>> x.itemsize
|
Chris@87
|
2619 16
|
Chris@87
|
2620
|
Chris@87
|
2621 """))
|
Chris@87
|
2622
|
Chris@87
|
2623
|
Chris@87
|
2624 add_newdoc('numpy.core.multiarray', 'ndarray', ('flags',
|
Chris@87
|
2625 """
|
Chris@87
|
2626 Information about the memory layout of the array.
|
Chris@87
|
2627
|
Chris@87
|
2628 Attributes
|
Chris@87
|
2629 ----------
|
Chris@87
|
2630 C_CONTIGUOUS (C)
|
Chris@87
|
2631 The data is in a single, C-style contiguous segment.
|
Chris@87
|
2632 F_CONTIGUOUS (F)
|
Chris@87
|
2633 The data is in a single, Fortran-style contiguous segment.
|
Chris@87
|
2634 OWNDATA (O)
|
Chris@87
|
2635 The array owns the memory it uses or borrows it from another object.
|
Chris@87
|
2636 WRITEABLE (W)
|
Chris@87
|
2637 The data area can be written to. Setting this to False locks
|
Chris@87
|
2638 the data, making it read-only. A view (slice, etc.) inherits WRITEABLE
|
Chris@87
|
2639 from its base array at creation time, but a view of a writeable
|
Chris@87
|
2640 array may be subsequently locked while the base array remains writeable.
|
Chris@87
|
2641 (The opposite is not true, in that a view of a locked array may not
|
Chris@87
|
2642 be made writeable. However, currently, locking a base object does not
|
Chris@87
|
2643 lock any views that already reference it, so under that circumstance it
|
Chris@87
|
2644 is possible to alter the contents of a locked array via a previously
|
Chris@87
|
2645 created writeable view onto it.) Attempting to change a non-writeable
|
Chris@87
|
2646 array raises a RuntimeError exception.
|
Chris@87
|
2647 ALIGNED (A)
|
Chris@87
|
2648 The data and all elements are aligned appropriately for the hardware.
|
Chris@87
|
2649 UPDATEIFCOPY (U)
|
Chris@87
|
2650 This array is a copy of some other array. When this array is
|
Chris@87
|
2651 deallocated, the base array will be updated with the contents of
|
Chris@87
|
2652 this array.
|
Chris@87
|
2653 FNC
|
Chris@87
|
2654 F_CONTIGUOUS and not C_CONTIGUOUS.
|
Chris@87
|
2655 FORC
|
Chris@87
|
2656 F_CONTIGUOUS or C_CONTIGUOUS (one-segment test).
|
Chris@87
|
2657 BEHAVED (B)
|
Chris@87
|
2658 ALIGNED and WRITEABLE.
|
Chris@87
|
2659 CARRAY (CA)
|
Chris@87
|
2660 BEHAVED and C_CONTIGUOUS.
|
Chris@87
|
2661 FARRAY (FA)
|
Chris@87
|
2662 BEHAVED and F_CONTIGUOUS and not C_CONTIGUOUS.
|
Chris@87
|
2663
|
Chris@87
|
2664 Notes
|
Chris@87
|
2665 -----
|
Chris@87
|
2666 The `flags` object can be accessed dictionary-like (as in ``a.flags['WRITEABLE']``),
|
Chris@87
|
2667 or by using lowercased attribute names (as in ``a.flags.writeable``). Short flag
|
Chris@87
|
2668 names are only supported in dictionary access.
|
Chris@87
|
2669
|
Chris@87
|
2670 Only the UPDATEIFCOPY, WRITEABLE, and ALIGNED flags can be changed by
|
Chris@87
|
2671 the user, via direct assignment to the attribute or dictionary entry,
|
Chris@87
|
2672 or by calling `ndarray.setflags`.
|
Chris@87
|
2673
|
Chris@87
|
2674 The array flags cannot be set arbitrarily:
|
Chris@87
|
2675
|
Chris@87
|
2676 - UPDATEIFCOPY can only be set ``False``.
|
Chris@87
|
2677 - ALIGNED can only be set ``True`` if the data is truly aligned.
|
Chris@87
|
2678 - WRITEABLE can only be set ``True`` if the array owns its own memory
|
Chris@87
|
2679 or the ultimate owner of the memory exposes a writeable buffer
|
Chris@87
|
2680 interface or is a string.
|
Chris@87
|
2681
|
Chris@87
|
2682 Arrays can be both C-style and Fortran-style contiguous simultaneously.
|
Chris@87
|
2683 This is clear for 1-dimensional arrays, but can also be true for higher
|
Chris@87
|
2684 dimensional arrays.
|
Chris@87
|
2685
|
Chris@87
|
2686 Even for contiguous arrays a stride for a given dimension
|
Chris@87
|
2687 ``arr.strides[dim]`` may be *arbitrary* if ``arr.shape[dim] == 1``
|
Chris@87
|
2688 or the array has no elements.
|
Chris@87
|
2689 It does *not* generally hold that ``self.strides[-1] == self.itemsize``
|
Chris@87
|
2690 for C-style contiguous arrays or ``self.strides[0] == self.itemsize`` for
|
Chris@87
|
2691 Fortran-style contiguous arrays is true.
|
Chris@87
|
2692 """))
|
Chris@87
|
2693
|
Chris@87
|
2694
|
Chris@87
|
2695 add_newdoc('numpy.core.multiarray', 'ndarray', ('flat',
|
Chris@87
|
2696 """
|
Chris@87
|
2697 A 1-D iterator over the array.
|
Chris@87
|
2698
|
Chris@87
|
2699 This is a `numpy.flatiter` instance, which acts similarly to, but is not
|
Chris@87
|
2700 a subclass of, Python's built-in iterator object.
|
Chris@87
|
2701
|
Chris@87
|
2702 See Also
|
Chris@87
|
2703 --------
|
Chris@87
|
2704 flatten : Return a copy of the array collapsed into one dimension.
|
Chris@87
|
2705
|
Chris@87
|
2706 flatiter
|
Chris@87
|
2707
|
Chris@87
|
2708 Examples
|
Chris@87
|
2709 --------
|
Chris@87
|
2710 >>> x = np.arange(1, 7).reshape(2, 3)
|
Chris@87
|
2711 >>> x
|
Chris@87
|
2712 array([[1, 2, 3],
|
Chris@87
|
2713 [4, 5, 6]])
|
Chris@87
|
2714 >>> x.flat[3]
|
Chris@87
|
2715 4
|
Chris@87
|
2716 >>> x.T
|
Chris@87
|
2717 array([[1, 4],
|
Chris@87
|
2718 [2, 5],
|
Chris@87
|
2719 [3, 6]])
|
Chris@87
|
2720 >>> x.T.flat[3]
|
Chris@87
|
2721 5
|
Chris@87
|
2722 >>> type(x.flat)
|
Chris@87
|
2723 <type 'numpy.flatiter'>
|
Chris@87
|
2724
|
Chris@87
|
2725 An assignment example:
|
Chris@87
|
2726
|
Chris@87
|
2727 >>> x.flat = 3; x
|
Chris@87
|
2728 array([[3, 3, 3],
|
Chris@87
|
2729 [3, 3, 3]])
|
Chris@87
|
2730 >>> x.flat[[1,4]] = 1; x
|
Chris@87
|
2731 array([[3, 1, 3],
|
Chris@87
|
2732 [3, 1, 3]])
|
Chris@87
|
2733
|
Chris@87
|
2734 """))
|
Chris@87
|
2735
|
Chris@87
|
2736
|
Chris@87
|
2737 add_newdoc('numpy.core.multiarray', 'ndarray', ('nbytes',
|
Chris@87
|
2738 """
|
Chris@87
|
2739 Total bytes consumed by the elements of the array.
|
Chris@87
|
2740
|
Chris@87
|
2741 Notes
|
Chris@87
|
2742 -----
|
Chris@87
|
2743 Does not include memory consumed by non-element attributes of the
|
Chris@87
|
2744 array object.
|
Chris@87
|
2745
|
Chris@87
|
2746 Examples
|
Chris@87
|
2747 --------
|
Chris@87
|
2748 >>> x = np.zeros((3,5,2), dtype=np.complex128)
|
Chris@87
|
2749 >>> x.nbytes
|
Chris@87
|
2750 480
|
Chris@87
|
2751 >>> np.prod(x.shape) * x.itemsize
|
Chris@87
|
2752 480
|
Chris@87
|
2753
|
Chris@87
|
2754 """))
|
Chris@87
|
2755
|
Chris@87
|
2756
|
Chris@87
|
2757 add_newdoc('numpy.core.multiarray', 'ndarray', ('ndim',
|
Chris@87
|
2758 """
|
Chris@87
|
2759 Number of array dimensions.
|
Chris@87
|
2760
|
Chris@87
|
2761 Examples
|
Chris@87
|
2762 --------
|
Chris@87
|
2763 >>> x = np.array([1, 2, 3])
|
Chris@87
|
2764 >>> x.ndim
|
Chris@87
|
2765 1
|
Chris@87
|
2766 >>> y = np.zeros((2, 3, 4))
|
Chris@87
|
2767 >>> y.ndim
|
Chris@87
|
2768 3
|
Chris@87
|
2769
|
Chris@87
|
2770 """))
|
Chris@87
|
2771
|
Chris@87
|
2772
|
Chris@87
|
2773 add_newdoc('numpy.core.multiarray', 'ndarray', ('real',
|
Chris@87
|
2774 """
|
Chris@87
|
2775 The real part of the array.
|
Chris@87
|
2776
|
Chris@87
|
2777 Examples
|
Chris@87
|
2778 --------
|
Chris@87
|
2779 >>> x = np.sqrt([1+0j, 0+1j])
|
Chris@87
|
2780 >>> x.real
|
Chris@87
|
2781 array([ 1. , 0.70710678])
|
Chris@87
|
2782 >>> x.real.dtype
|
Chris@87
|
2783 dtype('float64')
|
Chris@87
|
2784
|
Chris@87
|
2785 See Also
|
Chris@87
|
2786 --------
|
Chris@87
|
2787 numpy.real : equivalent function
|
Chris@87
|
2788
|
Chris@87
|
2789 """))
|
Chris@87
|
2790
|
Chris@87
|
2791
|
Chris@87
|
2792 add_newdoc('numpy.core.multiarray', 'ndarray', ('shape',
|
Chris@87
|
2793 """
|
Chris@87
|
2794 Tuple of array dimensions.
|
Chris@87
|
2795
|
Chris@87
|
2796 Notes
|
Chris@87
|
2797 -----
|
Chris@87
|
2798 May be used to "reshape" the array, as long as this would not
|
Chris@87
|
2799 require a change in the total number of elements
|
Chris@87
|
2800
|
Chris@87
|
2801 Examples
|
Chris@87
|
2802 --------
|
Chris@87
|
2803 >>> x = np.array([1, 2, 3, 4])
|
Chris@87
|
2804 >>> x.shape
|
Chris@87
|
2805 (4,)
|
Chris@87
|
2806 >>> y = np.zeros((2, 3, 4))
|
Chris@87
|
2807 >>> y.shape
|
Chris@87
|
2808 (2, 3, 4)
|
Chris@87
|
2809 >>> y.shape = (3, 8)
|
Chris@87
|
2810 >>> y
|
Chris@87
|
2811 array([[ 0., 0., 0., 0., 0., 0., 0., 0.],
|
Chris@87
|
2812 [ 0., 0., 0., 0., 0., 0., 0., 0.],
|
Chris@87
|
2813 [ 0., 0., 0., 0., 0., 0., 0., 0.]])
|
Chris@87
|
2814 >>> y.shape = (3, 6)
|
Chris@87
|
2815 Traceback (most recent call last):
|
Chris@87
|
2816 File "<stdin>", line 1, in <module>
|
Chris@87
|
2817 ValueError: total size of new array must be unchanged
|
Chris@87
|
2818
|
Chris@87
|
2819 """))
|
Chris@87
|
2820
|
Chris@87
|
2821
|
Chris@87
|
2822 add_newdoc('numpy.core.multiarray', 'ndarray', ('size',
|
Chris@87
|
2823 """
|
Chris@87
|
2824 Number of elements in the array.
|
Chris@87
|
2825
|
Chris@87
|
2826 Equivalent to ``np.prod(a.shape)``, i.e., the product of the array's
|
Chris@87
|
2827 dimensions.
|
Chris@87
|
2828
|
Chris@87
|
2829 Examples
|
Chris@87
|
2830 --------
|
Chris@87
|
2831 >>> x = np.zeros((3, 5, 2), dtype=np.complex128)
|
Chris@87
|
2832 >>> x.size
|
Chris@87
|
2833 30
|
Chris@87
|
2834 >>> np.prod(x.shape)
|
Chris@87
|
2835 30
|
Chris@87
|
2836
|
Chris@87
|
2837 """))
|
Chris@87
|
2838
|
Chris@87
|
2839
|
Chris@87
|
2840 add_newdoc('numpy.core.multiarray', 'ndarray', ('strides',
|
Chris@87
|
2841 """
|
Chris@87
|
2842 Tuple of bytes to step in each dimension when traversing an array.
|
Chris@87
|
2843
|
Chris@87
|
2844 The byte offset of element ``(i[0], i[1], ..., i[n])`` in an array `a`
|
Chris@87
|
2845 is::
|
Chris@87
|
2846
|
Chris@87
|
2847 offset = sum(np.array(i) * a.strides)
|
Chris@87
|
2848
|
Chris@87
|
2849 A more detailed explanation of strides can be found in the
|
Chris@87
|
2850 "ndarray.rst" file in the NumPy reference guide.
|
Chris@87
|
2851
|
Chris@87
|
2852 Notes
|
Chris@87
|
2853 -----
|
Chris@87
|
2854 Imagine an array of 32-bit integers (each 4 bytes)::
|
Chris@87
|
2855
|
Chris@87
|
2856 x = np.array([[0, 1, 2, 3, 4],
|
Chris@87
|
2857 [5, 6, 7, 8, 9]], dtype=np.int32)
|
Chris@87
|
2858
|
Chris@87
|
2859 This array is stored in memory as 40 bytes, one after the other
|
Chris@87
|
2860 (known as a contiguous block of memory). The strides of an array tell
|
Chris@87
|
2861 us how many bytes we have to skip in memory to move to the next position
|
Chris@87
|
2862 along a certain axis. For example, we have to skip 4 bytes (1 value) to
|
Chris@87
|
2863 move to the next column, but 20 bytes (5 values) to get to the same
|
Chris@87
|
2864 position in the next row. As such, the strides for the array `x` will be
|
Chris@87
|
2865 ``(20, 4)``.
|
Chris@87
|
2866
|
Chris@87
|
2867 See Also
|
Chris@87
|
2868 --------
|
Chris@87
|
2869 numpy.lib.stride_tricks.as_strided
|
Chris@87
|
2870
|
Chris@87
|
2871 Examples
|
Chris@87
|
2872 --------
|
Chris@87
|
2873 >>> y = np.reshape(np.arange(2*3*4), (2,3,4))
|
Chris@87
|
2874 >>> y
|
Chris@87
|
2875 array([[[ 0, 1, 2, 3],
|
Chris@87
|
2876 [ 4, 5, 6, 7],
|
Chris@87
|
2877 [ 8, 9, 10, 11]],
|
Chris@87
|
2878 [[12, 13, 14, 15],
|
Chris@87
|
2879 [16, 17, 18, 19],
|
Chris@87
|
2880 [20, 21, 22, 23]]])
|
Chris@87
|
2881 >>> y.strides
|
Chris@87
|
2882 (48, 16, 4)
|
Chris@87
|
2883 >>> y[1,1,1]
|
Chris@87
|
2884 17
|
Chris@87
|
2885 >>> offset=sum(y.strides * np.array((1,1,1)))
|
Chris@87
|
2886 >>> offset/y.itemsize
|
Chris@87
|
2887 17
|
Chris@87
|
2888
|
Chris@87
|
2889 >>> x = np.reshape(np.arange(5*6*7*8), (5,6,7,8)).transpose(2,3,1,0)
|
Chris@87
|
2890 >>> x.strides
|
Chris@87
|
2891 (32, 4, 224, 1344)
|
Chris@87
|
2892 >>> i = np.array([3,5,2,2])
|
Chris@87
|
2893 >>> offset = sum(i * x.strides)
|
Chris@87
|
2894 >>> x[3,5,2,2]
|
Chris@87
|
2895 813
|
Chris@87
|
2896 >>> offset / x.itemsize
|
Chris@87
|
2897 813
|
Chris@87
|
2898
|
Chris@87
|
2899 """))
|
Chris@87
|
2900
|
Chris@87
|
2901
|
Chris@87
|
2902 add_newdoc('numpy.core.multiarray', 'ndarray', ('T',
|
Chris@87
|
2903 """
|
Chris@87
|
2904 Same as self.transpose(), except that self is returned if
|
Chris@87
|
2905 self.ndim < 2.
|
Chris@87
|
2906
|
Chris@87
|
2907 Examples
|
Chris@87
|
2908 --------
|
Chris@87
|
2909 >>> x = np.array([[1.,2.],[3.,4.]])
|
Chris@87
|
2910 >>> x
|
Chris@87
|
2911 array([[ 1., 2.],
|
Chris@87
|
2912 [ 3., 4.]])
|
Chris@87
|
2913 >>> x.T
|
Chris@87
|
2914 array([[ 1., 3.],
|
Chris@87
|
2915 [ 2., 4.]])
|
Chris@87
|
2916 >>> x = np.array([1.,2.,3.,4.])
|
Chris@87
|
2917 >>> x
|
Chris@87
|
2918 array([ 1., 2., 3., 4.])
|
Chris@87
|
2919 >>> x.T
|
Chris@87
|
2920 array([ 1., 2., 3., 4.])
|
Chris@87
|
2921
|
Chris@87
|
2922 """))
|
Chris@87
|
2923
|
Chris@87
|
2924
|
Chris@87
|
2925 ##############################################################################
|
Chris@87
|
2926 #
|
Chris@87
|
2927 # ndarray methods
|
Chris@87
|
2928 #
|
Chris@87
|
2929 ##############################################################################
|
Chris@87
|
2930
|
Chris@87
|
2931
|
Chris@87
|
2932 add_newdoc('numpy.core.multiarray', 'ndarray', ('__array__',
|
Chris@87
|
2933 """ a.__array__(|dtype) -> reference if type unchanged, copy otherwise.
|
Chris@87
|
2934
|
Chris@87
|
2935 Returns either a new reference to self if dtype is not given or a new array
|
Chris@87
|
2936 of provided data type if dtype is different from the current dtype of the
|
Chris@87
|
2937 array.
|
Chris@87
|
2938
|
Chris@87
|
2939 """))
|
Chris@87
|
2940
|
Chris@87
|
2941
|
Chris@87
|
2942 add_newdoc('numpy.core.multiarray', 'ndarray', ('__array_prepare__',
|
Chris@87
|
2943 """a.__array_prepare__(obj) -> Object of same type as ndarray object obj.
|
Chris@87
|
2944
|
Chris@87
|
2945 """))
|
Chris@87
|
2946
|
Chris@87
|
2947
|
Chris@87
|
2948 add_newdoc('numpy.core.multiarray', 'ndarray', ('__array_wrap__',
|
Chris@87
|
2949 """a.__array_wrap__(obj) -> Object of same type as ndarray object a.
|
Chris@87
|
2950
|
Chris@87
|
2951 """))
|
Chris@87
|
2952
|
Chris@87
|
2953
|
Chris@87
|
2954 add_newdoc('numpy.core.multiarray', 'ndarray', ('__copy__',
|
Chris@87
|
2955 """a.__copy__([order])
|
Chris@87
|
2956
|
Chris@87
|
2957 Return a copy of the array.
|
Chris@87
|
2958
|
Chris@87
|
2959 Parameters
|
Chris@87
|
2960 ----------
|
Chris@87
|
2961 order : {'C', 'F', 'A'}, optional
|
Chris@87
|
2962 If order is 'C' (False) then the result is contiguous (default).
|
Chris@87
|
2963 If order is 'Fortran' (True) then the result has fortran order.
|
Chris@87
|
2964 If order is 'Any' (None) then the result has fortran order
|
Chris@87
|
2965 only if the array already is in fortran order.
|
Chris@87
|
2966
|
Chris@87
|
2967 """))
|
Chris@87
|
2968
|
Chris@87
|
2969
|
Chris@87
|
2970 add_newdoc('numpy.core.multiarray', 'ndarray', ('__deepcopy__',
|
Chris@87
|
2971 """a.__deepcopy__() -> Deep copy of array.
|
Chris@87
|
2972
|
Chris@87
|
2973 Used if copy.deepcopy is called on an array.
|
Chris@87
|
2974
|
Chris@87
|
2975 """))
|
Chris@87
|
2976
|
Chris@87
|
2977
|
Chris@87
|
2978 add_newdoc('numpy.core.multiarray', 'ndarray', ('__reduce__',
|
Chris@87
|
2979 """a.__reduce__()
|
Chris@87
|
2980
|
Chris@87
|
2981 For pickling.
|
Chris@87
|
2982
|
Chris@87
|
2983 """))
|
Chris@87
|
2984
|
Chris@87
|
2985
|
Chris@87
|
2986 add_newdoc('numpy.core.multiarray', 'ndarray', ('__setstate__',
|
Chris@87
|
2987 """a.__setstate__(version, shape, dtype, isfortran, rawdata)
|
Chris@87
|
2988
|
Chris@87
|
2989 For unpickling.
|
Chris@87
|
2990
|
Chris@87
|
2991 Parameters
|
Chris@87
|
2992 ----------
|
Chris@87
|
2993 version : int
|
Chris@87
|
2994 optional pickle version. If omitted defaults to 0.
|
Chris@87
|
2995 shape : tuple
|
Chris@87
|
2996 dtype : data-type
|
Chris@87
|
2997 isFortran : bool
|
Chris@87
|
2998 rawdata : string or list
|
Chris@87
|
2999 a binary string with the data (or a list if 'a' is an object array)
|
Chris@87
|
3000
|
Chris@87
|
3001 """))
|
Chris@87
|
3002
|
Chris@87
|
3003
|
Chris@87
|
3004 add_newdoc('numpy.core.multiarray', 'ndarray', ('all',
|
Chris@87
|
3005 """
|
Chris@87
|
3006 a.all(axis=None, out=None)
|
Chris@87
|
3007
|
Chris@87
|
3008 Returns True if all elements evaluate to True.
|
Chris@87
|
3009
|
Chris@87
|
3010 Refer to `numpy.all` for full documentation.
|
Chris@87
|
3011
|
Chris@87
|
3012 See Also
|
Chris@87
|
3013 --------
|
Chris@87
|
3014 numpy.all : equivalent function
|
Chris@87
|
3015
|
Chris@87
|
3016 """))
|
Chris@87
|
3017
|
Chris@87
|
3018
|
Chris@87
|
3019 add_newdoc('numpy.core.multiarray', 'ndarray', ('any',
|
Chris@87
|
3020 """
|
Chris@87
|
3021 a.any(axis=None, out=None)
|
Chris@87
|
3022
|
Chris@87
|
3023 Returns True if any of the elements of `a` evaluate to True.
|
Chris@87
|
3024
|
Chris@87
|
3025 Refer to `numpy.any` for full documentation.
|
Chris@87
|
3026
|
Chris@87
|
3027 See Also
|
Chris@87
|
3028 --------
|
Chris@87
|
3029 numpy.any : equivalent function
|
Chris@87
|
3030
|
Chris@87
|
3031 """))
|
Chris@87
|
3032
|
Chris@87
|
3033
|
Chris@87
|
3034 add_newdoc('numpy.core.multiarray', 'ndarray', ('argmax',
|
Chris@87
|
3035 """
|
Chris@87
|
3036 a.argmax(axis=None, out=None)
|
Chris@87
|
3037
|
Chris@87
|
3038 Return indices of the maximum values along the given axis.
|
Chris@87
|
3039
|
Chris@87
|
3040 Refer to `numpy.argmax` for full documentation.
|
Chris@87
|
3041
|
Chris@87
|
3042 See Also
|
Chris@87
|
3043 --------
|
Chris@87
|
3044 numpy.argmax : equivalent function
|
Chris@87
|
3045
|
Chris@87
|
3046 """))
|
Chris@87
|
3047
|
Chris@87
|
3048
|
Chris@87
|
3049 add_newdoc('numpy.core.multiarray', 'ndarray', ('argmin',
|
Chris@87
|
3050 """
|
Chris@87
|
3051 a.argmin(axis=None, out=None)
|
Chris@87
|
3052
|
Chris@87
|
3053 Return indices of the minimum values along the given axis of `a`.
|
Chris@87
|
3054
|
Chris@87
|
3055 Refer to `numpy.argmin` for detailed documentation.
|
Chris@87
|
3056
|
Chris@87
|
3057 See Also
|
Chris@87
|
3058 --------
|
Chris@87
|
3059 numpy.argmin : equivalent function
|
Chris@87
|
3060
|
Chris@87
|
3061 """))
|
Chris@87
|
3062
|
Chris@87
|
3063
|
Chris@87
|
3064 add_newdoc('numpy.core.multiarray', 'ndarray', ('argsort',
|
Chris@87
|
3065 """
|
Chris@87
|
3066 a.argsort(axis=-1, kind='quicksort', order=None)
|
Chris@87
|
3067
|
Chris@87
|
3068 Returns the indices that would sort this array.
|
Chris@87
|
3069
|
Chris@87
|
3070 Refer to `numpy.argsort` for full documentation.
|
Chris@87
|
3071
|
Chris@87
|
3072 See Also
|
Chris@87
|
3073 --------
|
Chris@87
|
3074 numpy.argsort : equivalent function
|
Chris@87
|
3075
|
Chris@87
|
3076 """))
|
Chris@87
|
3077
|
Chris@87
|
3078
|
Chris@87
|
3079 add_newdoc('numpy.core.multiarray', 'ndarray', ('argpartition',
|
Chris@87
|
3080 """
|
Chris@87
|
3081 a.argpartition(kth, axis=-1, kind='introselect', order=None)
|
Chris@87
|
3082
|
Chris@87
|
3083 Returns the indices that would partition this array.
|
Chris@87
|
3084
|
Chris@87
|
3085 Refer to `numpy.argpartition` for full documentation.
|
Chris@87
|
3086
|
Chris@87
|
3087 .. versionadded:: 1.8.0
|
Chris@87
|
3088
|
Chris@87
|
3089 See Also
|
Chris@87
|
3090 --------
|
Chris@87
|
3091 numpy.argpartition : equivalent function
|
Chris@87
|
3092
|
Chris@87
|
3093 """))
|
Chris@87
|
3094
|
Chris@87
|
3095
|
Chris@87
|
3096 add_newdoc('numpy.core.multiarray', 'ndarray', ('astype',
|
Chris@87
|
3097 """
|
Chris@87
|
3098 a.astype(dtype, order='K', casting='unsafe', subok=True, copy=True)
|
Chris@87
|
3099
|
Chris@87
|
3100 Copy of the array, cast to a specified type.
|
Chris@87
|
3101
|
Chris@87
|
3102 Parameters
|
Chris@87
|
3103 ----------
|
Chris@87
|
3104 dtype : str or dtype
|
Chris@87
|
3105 Typecode or data-type to which the array is cast.
|
Chris@87
|
3106 order : {'C', 'F', 'A', 'K'}, optional
|
Chris@87
|
3107 Controls the memory layout order of the result.
|
Chris@87
|
3108 'C' means C order, 'F' means Fortran order, 'A'
|
Chris@87
|
3109 means 'F' order if all the arrays are Fortran contiguous,
|
Chris@87
|
3110 'C' order otherwise, and 'K' means as close to the
|
Chris@87
|
3111 order the array elements appear in memory as possible.
|
Chris@87
|
3112 Default is 'K'.
|
Chris@87
|
3113 casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
|
Chris@87
|
3114 Controls what kind of data casting may occur. Defaults to 'unsafe'
|
Chris@87
|
3115 for backwards compatibility.
|
Chris@87
|
3116
|
Chris@87
|
3117 * 'no' means the data types should not be cast at all.
|
Chris@87
|
3118 * 'equiv' means only byte-order changes are allowed.
|
Chris@87
|
3119 * 'safe' means only casts which can preserve values are allowed.
|
Chris@87
|
3120 * 'same_kind' means only safe casts or casts within a kind,
|
Chris@87
|
3121 like float64 to float32, are allowed.
|
Chris@87
|
3122 * 'unsafe' means any data conversions may be done.
|
Chris@87
|
3123 subok : bool, optional
|
Chris@87
|
3124 If True, then sub-classes will be passed-through (default), otherwise
|
Chris@87
|
3125 the returned array will be forced to be a base-class array.
|
Chris@87
|
3126 copy : bool, optional
|
Chris@87
|
3127 By default, astype always returns a newly allocated array. If this
|
Chris@87
|
3128 is set to false, and the `dtype`, `order`, and `subok`
|
Chris@87
|
3129 requirements are satisfied, the input array is returned instead
|
Chris@87
|
3130 of a copy.
|
Chris@87
|
3131
|
Chris@87
|
3132 Returns
|
Chris@87
|
3133 -------
|
Chris@87
|
3134 arr_t : ndarray
|
Chris@87
|
3135 Unless `copy` is False and the other conditions for returning the input
|
Chris@87
|
3136 array are satisfied (see description for `copy` input paramter), `arr_t`
|
Chris@87
|
3137 is a new array of the same shape as the input array, with dtype, order
|
Chris@87
|
3138 given by `dtype`, `order`.
|
Chris@87
|
3139
|
Chris@87
|
3140 Notes
|
Chris@87
|
3141 -----
|
Chris@87
|
3142 Starting in NumPy 1.9, astype method now returns an error if the string
|
Chris@87
|
3143 dtype to cast to is not long enough in 'safe' casting mode to hold the max
|
Chris@87
|
3144 value of integer/float array that is being casted. Previously the casting
|
Chris@87
|
3145 was allowed even if the result was truncated.
|
Chris@87
|
3146
|
Chris@87
|
3147 Raises
|
Chris@87
|
3148 ------
|
Chris@87
|
3149 ComplexWarning
|
Chris@87
|
3150 When casting from complex to float or int. To avoid this,
|
Chris@87
|
3151 one should use ``a.real.astype(t)``.
|
Chris@87
|
3152
|
Chris@87
|
3153 Examples
|
Chris@87
|
3154 --------
|
Chris@87
|
3155 >>> x = np.array([1, 2, 2.5])
|
Chris@87
|
3156 >>> x
|
Chris@87
|
3157 array([ 1. , 2. , 2.5])
|
Chris@87
|
3158
|
Chris@87
|
3159 >>> x.astype(int)
|
Chris@87
|
3160 array([1, 2, 2])
|
Chris@87
|
3161
|
Chris@87
|
3162 """))
|
Chris@87
|
3163
|
Chris@87
|
3164
|
Chris@87
|
3165 add_newdoc('numpy.core.multiarray', 'ndarray', ('byteswap',
|
Chris@87
|
3166 """
|
Chris@87
|
3167 a.byteswap(inplace)
|
Chris@87
|
3168
|
Chris@87
|
3169 Swap the bytes of the array elements
|
Chris@87
|
3170
|
Chris@87
|
3171 Toggle between low-endian and big-endian data representation by
|
Chris@87
|
3172 returning a byteswapped array, optionally swapped in-place.
|
Chris@87
|
3173
|
Chris@87
|
3174 Parameters
|
Chris@87
|
3175 ----------
|
Chris@87
|
3176 inplace : bool, optional
|
Chris@87
|
3177 If ``True``, swap bytes in-place, default is ``False``.
|
Chris@87
|
3178
|
Chris@87
|
3179 Returns
|
Chris@87
|
3180 -------
|
Chris@87
|
3181 out : ndarray
|
Chris@87
|
3182 The byteswapped array. If `inplace` is ``True``, this is
|
Chris@87
|
3183 a view to self.
|
Chris@87
|
3184
|
Chris@87
|
3185 Examples
|
Chris@87
|
3186 --------
|
Chris@87
|
3187 >>> A = np.array([1, 256, 8755], dtype=np.int16)
|
Chris@87
|
3188 >>> map(hex, A)
|
Chris@87
|
3189 ['0x1', '0x100', '0x2233']
|
Chris@87
|
3190 >>> A.byteswap(True)
|
Chris@87
|
3191 array([ 256, 1, 13090], dtype=int16)
|
Chris@87
|
3192 >>> map(hex, A)
|
Chris@87
|
3193 ['0x100', '0x1', '0x3322']
|
Chris@87
|
3194
|
Chris@87
|
3195 Arrays of strings are not swapped
|
Chris@87
|
3196
|
Chris@87
|
3197 >>> A = np.array(['ceg', 'fac'])
|
Chris@87
|
3198 >>> A.byteswap()
|
Chris@87
|
3199 array(['ceg', 'fac'],
|
Chris@87
|
3200 dtype='|S3')
|
Chris@87
|
3201
|
Chris@87
|
3202 """))
|
Chris@87
|
3203
|
Chris@87
|
3204
|
Chris@87
|
3205 add_newdoc('numpy.core.multiarray', 'ndarray', ('choose',
|
Chris@87
|
3206 """
|
Chris@87
|
3207 a.choose(choices, out=None, mode='raise')
|
Chris@87
|
3208
|
Chris@87
|
3209 Use an index array to construct a new array from a set of choices.
|
Chris@87
|
3210
|
Chris@87
|
3211 Refer to `numpy.choose` for full documentation.
|
Chris@87
|
3212
|
Chris@87
|
3213 See Also
|
Chris@87
|
3214 --------
|
Chris@87
|
3215 numpy.choose : equivalent function
|
Chris@87
|
3216
|
Chris@87
|
3217 """))
|
Chris@87
|
3218
|
Chris@87
|
3219
|
Chris@87
|
3220 add_newdoc('numpy.core.multiarray', 'ndarray', ('clip',
|
Chris@87
|
3221 """
|
Chris@87
|
3222 a.clip(a_min, a_max, out=None)
|
Chris@87
|
3223
|
Chris@87
|
3224 Return an array whose values are limited to ``[a_min, a_max]``.
|
Chris@87
|
3225
|
Chris@87
|
3226 Refer to `numpy.clip` for full documentation.
|
Chris@87
|
3227
|
Chris@87
|
3228 See Also
|
Chris@87
|
3229 --------
|
Chris@87
|
3230 numpy.clip : equivalent function
|
Chris@87
|
3231
|
Chris@87
|
3232 """))
|
Chris@87
|
3233
|
Chris@87
|
3234
|
Chris@87
|
3235 add_newdoc('numpy.core.multiarray', 'ndarray', ('compress',
|
Chris@87
|
3236 """
|
Chris@87
|
3237 a.compress(condition, axis=None, out=None)
|
Chris@87
|
3238
|
Chris@87
|
3239 Return selected slices of this array along given axis.
|
Chris@87
|
3240
|
Chris@87
|
3241 Refer to `numpy.compress` for full documentation.
|
Chris@87
|
3242
|
Chris@87
|
3243 See Also
|
Chris@87
|
3244 --------
|
Chris@87
|
3245 numpy.compress : equivalent function
|
Chris@87
|
3246
|
Chris@87
|
3247 """))
|
Chris@87
|
3248
|
Chris@87
|
3249
|
Chris@87
|
3250 add_newdoc('numpy.core.multiarray', 'ndarray', ('conj',
|
Chris@87
|
3251 """
|
Chris@87
|
3252 a.conj()
|
Chris@87
|
3253
|
Chris@87
|
3254 Complex-conjugate all elements.
|
Chris@87
|
3255
|
Chris@87
|
3256 Refer to `numpy.conjugate` for full documentation.
|
Chris@87
|
3257
|
Chris@87
|
3258 See Also
|
Chris@87
|
3259 --------
|
Chris@87
|
3260 numpy.conjugate : equivalent function
|
Chris@87
|
3261
|
Chris@87
|
3262 """))
|
Chris@87
|
3263
|
Chris@87
|
3264
|
Chris@87
|
3265 add_newdoc('numpy.core.multiarray', 'ndarray', ('conjugate',
|
Chris@87
|
3266 """
|
Chris@87
|
3267 a.conjugate()
|
Chris@87
|
3268
|
Chris@87
|
3269 Return the complex conjugate, element-wise.
|
Chris@87
|
3270
|
Chris@87
|
3271 Refer to `numpy.conjugate` for full documentation.
|
Chris@87
|
3272
|
Chris@87
|
3273 See Also
|
Chris@87
|
3274 --------
|
Chris@87
|
3275 numpy.conjugate : equivalent function
|
Chris@87
|
3276
|
Chris@87
|
3277 """))
|
Chris@87
|
3278
|
Chris@87
|
3279
|
Chris@87
|
3280 add_newdoc('numpy.core.multiarray', 'ndarray', ('copy',
|
Chris@87
|
3281 """
|
Chris@87
|
3282 a.copy(order='C')
|
Chris@87
|
3283
|
Chris@87
|
3284 Return a copy of the array.
|
Chris@87
|
3285
|
Chris@87
|
3286 Parameters
|
Chris@87
|
3287 ----------
|
Chris@87
|
3288 order : {'C', 'F', 'A', 'K'}, optional
|
Chris@87
|
3289 Controls the memory layout of the copy. 'C' means C-order,
|
Chris@87
|
3290 'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
|
Chris@87
|
3291 'C' otherwise. 'K' means match the layout of `a` as closely
|
Chris@87
|
3292 as possible. (Note that this function and :func:numpy.copy are very
|
Chris@87
|
3293 similar, but have different default values for their order=
|
Chris@87
|
3294 arguments.)
|
Chris@87
|
3295
|
Chris@87
|
3296 See also
|
Chris@87
|
3297 --------
|
Chris@87
|
3298 numpy.copy
|
Chris@87
|
3299 numpy.copyto
|
Chris@87
|
3300
|
Chris@87
|
3301 Examples
|
Chris@87
|
3302 --------
|
Chris@87
|
3303 >>> x = np.array([[1,2,3],[4,5,6]], order='F')
|
Chris@87
|
3304
|
Chris@87
|
3305 >>> y = x.copy()
|
Chris@87
|
3306
|
Chris@87
|
3307 >>> x.fill(0)
|
Chris@87
|
3308
|
Chris@87
|
3309 >>> x
|
Chris@87
|
3310 array([[0, 0, 0],
|
Chris@87
|
3311 [0, 0, 0]])
|
Chris@87
|
3312
|
Chris@87
|
3313 >>> y
|
Chris@87
|
3314 array([[1, 2, 3],
|
Chris@87
|
3315 [4, 5, 6]])
|
Chris@87
|
3316
|
Chris@87
|
3317 >>> y.flags['C_CONTIGUOUS']
|
Chris@87
|
3318 True
|
Chris@87
|
3319
|
Chris@87
|
3320 """))
|
Chris@87
|
3321
|
Chris@87
|
3322
|
Chris@87
|
3323 add_newdoc('numpy.core.multiarray', 'ndarray', ('cumprod',
|
Chris@87
|
3324 """
|
Chris@87
|
3325 a.cumprod(axis=None, dtype=None, out=None)
|
Chris@87
|
3326
|
Chris@87
|
3327 Return the cumulative product of the elements along the given axis.
|
Chris@87
|
3328
|
Chris@87
|
3329 Refer to `numpy.cumprod` for full documentation.
|
Chris@87
|
3330
|
Chris@87
|
3331 See Also
|
Chris@87
|
3332 --------
|
Chris@87
|
3333 numpy.cumprod : equivalent function
|
Chris@87
|
3334
|
Chris@87
|
3335 """))
|
Chris@87
|
3336
|
Chris@87
|
3337
|
Chris@87
|
3338 add_newdoc('numpy.core.multiarray', 'ndarray', ('cumsum',
|
Chris@87
|
3339 """
|
Chris@87
|
3340 a.cumsum(axis=None, dtype=None, out=None)
|
Chris@87
|
3341
|
Chris@87
|
3342 Return the cumulative sum of the elements along the given axis.
|
Chris@87
|
3343
|
Chris@87
|
3344 Refer to `numpy.cumsum` for full documentation.
|
Chris@87
|
3345
|
Chris@87
|
3346 See Also
|
Chris@87
|
3347 --------
|
Chris@87
|
3348 numpy.cumsum : equivalent function
|
Chris@87
|
3349
|
Chris@87
|
3350 """))
|
Chris@87
|
3351
|
Chris@87
|
3352
|
Chris@87
|
3353 add_newdoc('numpy.core.multiarray', 'ndarray', ('diagonal',
|
Chris@87
|
3354 """
|
Chris@87
|
3355 a.diagonal(offset=0, axis1=0, axis2=1)
|
Chris@87
|
3356
|
Chris@87
|
3357 Return specified diagonals. In NumPy 1.9 the returned array is a
|
Chris@87
|
3358 read-only view instead of a copy as in previous NumPy versions. In
|
Chris@87
|
3359 NumPy 1.10 the read-only restriction will be removed.
|
Chris@87
|
3360
|
Chris@87
|
3361 Refer to :func:`numpy.diagonal` for full documentation.
|
Chris@87
|
3362
|
Chris@87
|
3363 See Also
|
Chris@87
|
3364 --------
|
Chris@87
|
3365 numpy.diagonal : equivalent function
|
Chris@87
|
3366
|
Chris@87
|
3367 """))
|
Chris@87
|
3368
|
Chris@87
|
3369
|
Chris@87
|
3370 add_newdoc('numpy.core.multiarray', 'ndarray', ('dot',
|
Chris@87
|
3371 """
|
Chris@87
|
3372 a.dot(b, out=None)
|
Chris@87
|
3373
|
Chris@87
|
3374 Dot product of two arrays.
|
Chris@87
|
3375
|
Chris@87
|
3376 Refer to `numpy.dot` for full documentation.
|
Chris@87
|
3377
|
Chris@87
|
3378 See Also
|
Chris@87
|
3379 --------
|
Chris@87
|
3380 numpy.dot : equivalent function
|
Chris@87
|
3381
|
Chris@87
|
3382 Examples
|
Chris@87
|
3383 --------
|
Chris@87
|
3384 >>> a = np.eye(2)
|
Chris@87
|
3385 >>> b = np.ones((2, 2)) * 2
|
Chris@87
|
3386 >>> a.dot(b)
|
Chris@87
|
3387 array([[ 2., 2.],
|
Chris@87
|
3388 [ 2., 2.]])
|
Chris@87
|
3389
|
Chris@87
|
3390 This array method can be conveniently chained:
|
Chris@87
|
3391
|
Chris@87
|
3392 >>> a.dot(b).dot(b)
|
Chris@87
|
3393 array([[ 8., 8.],
|
Chris@87
|
3394 [ 8., 8.]])
|
Chris@87
|
3395
|
Chris@87
|
3396 """))
|
Chris@87
|
3397
|
Chris@87
|
3398
|
Chris@87
|
3399 add_newdoc('numpy.core.multiarray', 'ndarray', ('dump',
|
Chris@87
|
3400 """a.dump(file)
|
Chris@87
|
3401
|
Chris@87
|
3402 Dump a pickle of the array to the specified file.
|
Chris@87
|
3403 The array can be read back with pickle.load or numpy.load.
|
Chris@87
|
3404
|
Chris@87
|
3405 Parameters
|
Chris@87
|
3406 ----------
|
Chris@87
|
3407 file : str
|
Chris@87
|
3408 A string naming the dump file.
|
Chris@87
|
3409
|
Chris@87
|
3410 """))
|
Chris@87
|
3411
|
Chris@87
|
3412
|
Chris@87
|
3413 add_newdoc('numpy.core.multiarray', 'ndarray', ('dumps',
|
Chris@87
|
3414 """
|
Chris@87
|
3415 a.dumps()
|
Chris@87
|
3416
|
Chris@87
|
3417 Returns the pickle of the array as a string.
|
Chris@87
|
3418 pickle.loads or numpy.loads will convert the string back to an array.
|
Chris@87
|
3419
|
Chris@87
|
3420 Parameters
|
Chris@87
|
3421 ----------
|
Chris@87
|
3422 None
|
Chris@87
|
3423
|
Chris@87
|
3424 """))
|
Chris@87
|
3425
|
Chris@87
|
3426
|
Chris@87
|
3427 add_newdoc('numpy.core.multiarray', 'ndarray', ('fill',
|
Chris@87
|
3428 """
|
Chris@87
|
3429 a.fill(value)
|
Chris@87
|
3430
|
Chris@87
|
3431 Fill the array with a scalar value.
|
Chris@87
|
3432
|
Chris@87
|
3433 Parameters
|
Chris@87
|
3434 ----------
|
Chris@87
|
3435 value : scalar
|
Chris@87
|
3436 All elements of `a` will be assigned this value.
|
Chris@87
|
3437
|
Chris@87
|
3438 Examples
|
Chris@87
|
3439 --------
|
Chris@87
|
3440 >>> a = np.array([1, 2])
|
Chris@87
|
3441 >>> a.fill(0)
|
Chris@87
|
3442 >>> a
|
Chris@87
|
3443 array([0, 0])
|
Chris@87
|
3444 >>> a = np.empty(2)
|
Chris@87
|
3445 >>> a.fill(1)
|
Chris@87
|
3446 >>> a
|
Chris@87
|
3447 array([ 1., 1.])
|
Chris@87
|
3448
|
Chris@87
|
3449 """))
|
Chris@87
|
3450
|
Chris@87
|
3451
|
Chris@87
|
3452 add_newdoc('numpy.core.multiarray', 'ndarray', ('flatten',
|
Chris@87
|
3453 """
|
Chris@87
|
3454 a.flatten(order='C')
|
Chris@87
|
3455
|
Chris@87
|
3456 Return a copy of the array collapsed into one dimension.
|
Chris@87
|
3457
|
Chris@87
|
3458 Parameters
|
Chris@87
|
3459 ----------
|
Chris@87
|
3460 order : {'C', 'F', 'A'}, optional
|
Chris@87
|
3461 Whether to flatten in C (row-major), Fortran (column-major) order,
|
Chris@87
|
3462 or preserve the C/Fortran ordering from `a`.
|
Chris@87
|
3463 The default is 'C'.
|
Chris@87
|
3464
|
Chris@87
|
3465 Returns
|
Chris@87
|
3466 -------
|
Chris@87
|
3467 y : ndarray
|
Chris@87
|
3468 A copy of the input array, flattened to one dimension.
|
Chris@87
|
3469
|
Chris@87
|
3470 See Also
|
Chris@87
|
3471 --------
|
Chris@87
|
3472 ravel : Return a flattened array.
|
Chris@87
|
3473 flat : A 1-D flat iterator over the array.
|
Chris@87
|
3474
|
Chris@87
|
3475 Examples
|
Chris@87
|
3476 --------
|
Chris@87
|
3477 >>> a = np.array([[1,2], [3,4]])
|
Chris@87
|
3478 >>> a.flatten()
|
Chris@87
|
3479 array([1, 2, 3, 4])
|
Chris@87
|
3480 >>> a.flatten('F')
|
Chris@87
|
3481 array([1, 3, 2, 4])
|
Chris@87
|
3482
|
Chris@87
|
3483 """))
|
Chris@87
|
3484
|
Chris@87
|
3485
|
Chris@87
|
3486 add_newdoc('numpy.core.multiarray', 'ndarray', ('getfield',
|
Chris@87
|
3487 """
|
Chris@87
|
3488 a.getfield(dtype, offset=0)
|
Chris@87
|
3489
|
Chris@87
|
3490 Returns a field of the given array as a certain type.
|
Chris@87
|
3491
|
Chris@87
|
3492 A field is a view of the array data with a given data-type. The values in
|
Chris@87
|
3493 the view are determined by the given type and the offset into the current
|
Chris@87
|
3494 array in bytes. The offset needs to be such that the view dtype fits in the
|
Chris@87
|
3495 array dtype; for example an array of dtype complex128 has 16-byte elements.
|
Chris@87
|
3496 If taking a view with a 32-bit integer (4 bytes), the offset needs to be
|
Chris@87
|
3497 between 0 and 12 bytes.
|
Chris@87
|
3498
|
Chris@87
|
3499 Parameters
|
Chris@87
|
3500 ----------
|
Chris@87
|
3501 dtype : str or dtype
|
Chris@87
|
3502 The data type of the view. The dtype size of the view can not be larger
|
Chris@87
|
3503 than that of the array itself.
|
Chris@87
|
3504 offset : int
|
Chris@87
|
3505 Number of bytes to skip before beginning the element view.
|
Chris@87
|
3506
|
Chris@87
|
3507 Examples
|
Chris@87
|
3508 --------
|
Chris@87
|
3509 >>> x = np.diag([1.+1.j]*2)
|
Chris@87
|
3510 >>> x[1, 1] = 2 + 4.j
|
Chris@87
|
3511 >>> x
|
Chris@87
|
3512 array([[ 1.+1.j, 0.+0.j],
|
Chris@87
|
3513 [ 0.+0.j, 2.+4.j]])
|
Chris@87
|
3514 >>> x.getfield(np.float64)
|
Chris@87
|
3515 array([[ 1., 0.],
|
Chris@87
|
3516 [ 0., 2.]])
|
Chris@87
|
3517
|
Chris@87
|
3518 By choosing an offset of 8 bytes we can select the complex part of the
|
Chris@87
|
3519 array for our view:
|
Chris@87
|
3520
|
Chris@87
|
3521 >>> x.getfield(np.float64, offset=8)
|
Chris@87
|
3522 array([[ 1., 0.],
|
Chris@87
|
3523 [ 0., 4.]])
|
Chris@87
|
3524
|
Chris@87
|
3525 """))
|
Chris@87
|
3526
|
Chris@87
|
3527
|
Chris@87
|
3528 add_newdoc('numpy.core.multiarray', 'ndarray', ('item',
|
Chris@87
|
3529 """
|
Chris@87
|
3530 a.item(*args)
|
Chris@87
|
3531
|
Chris@87
|
3532 Copy an element of an array to a standard Python scalar and return it.
|
Chris@87
|
3533
|
Chris@87
|
3534 Parameters
|
Chris@87
|
3535 ----------
|
Chris@87
|
3536 \\*args : Arguments (variable number and type)
|
Chris@87
|
3537
|
Chris@87
|
3538 * none: in this case, the method only works for arrays
|
Chris@87
|
3539 with one element (`a.size == 1`), which element is
|
Chris@87
|
3540 copied into a standard Python scalar object and returned.
|
Chris@87
|
3541
|
Chris@87
|
3542 * int_type: this argument is interpreted as a flat index into
|
Chris@87
|
3543 the array, specifying which element to copy and return.
|
Chris@87
|
3544
|
Chris@87
|
3545 * tuple of int_types: functions as does a single int_type argument,
|
Chris@87
|
3546 except that the argument is interpreted as an nd-index into the
|
Chris@87
|
3547 array.
|
Chris@87
|
3548
|
Chris@87
|
3549 Returns
|
Chris@87
|
3550 -------
|
Chris@87
|
3551 z : Standard Python scalar object
|
Chris@87
|
3552 A copy of the specified element of the array as a suitable
|
Chris@87
|
3553 Python scalar
|
Chris@87
|
3554
|
Chris@87
|
3555 Notes
|
Chris@87
|
3556 -----
|
Chris@87
|
3557 When the data type of `a` is longdouble or clongdouble, item() returns
|
Chris@87
|
3558 a scalar array object because there is no available Python scalar that
|
Chris@87
|
3559 would not lose information. Void arrays return a buffer object for item(),
|
Chris@87
|
3560 unless fields are defined, in which case a tuple is returned.
|
Chris@87
|
3561
|
Chris@87
|
3562 `item` is very similar to a[args], except, instead of an array scalar,
|
Chris@87
|
3563 a standard Python scalar is returned. This can be useful for speeding up
|
Chris@87
|
3564 access to elements of the array and doing arithmetic on elements of the
|
Chris@87
|
3565 array using Python's optimized math.
|
Chris@87
|
3566
|
Chris@87
|
3567 Examples
|
Chris@87
|
3568 --------
|
Chris@87
|
3569 >>> x = np.random.randint(9, size=(3, 3))
|
Chris@87
|
3570 >>> x
|
Chris@87
|
3571 array([[3, 1, 7],
|
Chris@87
|
3572 [2, 8, 3],
|
Chris@87
|
3573 [8, 5, 3]])
|
Chris@87
|
3574 >>> x.item(3)
|
Chris@87
|
3575 2
|
Chris@87
|
3576 >>> x.item(7)
|
Chris@87
|
3577 5
|
Chris@87
|
3578 >>> x.item((0, 1))
|
Chris@87
|
3579 1
|
Chris@87
|
3580 >>> x.item((2, 2))
|
Chris@87
|
3581 3
|
Chris@87
|
3582
|
Chris@87
|
3583 """))
|
Chris@87
|
3584
|
Chris@87
|
3585
|
Chris@87
|
3586 add_newdoc('numpy.core.multiarray', 'ndarray', ('itemset',
|
Chris@87
|
3587 """
|
Chris@87
|
3588 a.itemset(*args)
|
Chris@87
|
3589
|
Chris@87
|
3590 Insert scalar into an array (scalar is cast to array's dtype, if possible)
|
Chris@87
|
3591
|
Chris@87
|
3592 There must be at least 1 argument, and define the last argument
|
Chris@87
|
3593 as *item*. Then, ``a.itemset(*args)`` is equivalent to but faster
|
Chris@87
|
3594 than ``a[args] = item``. The item should be a scalar value and `args`
|
Chris@87
|
3595 must select a single item in the array `a`.
|
Chris@87
|
3596
|
Chris@87
|
3597 Parameters
|
Chris@87
|
3598 ----------
|
Chris@87
|
3599 \*args : Arguments
|
Chris@87
|
3600 If one argument: a scalar, only used in case `a` is of size 1.
|
Chris@87
|
3601 If two arguments: the last argument is the value to be set
|
Chris@87
|
3602 and must be a scalar, the first argument specifies a single array
|
Chris@87
|
3603 element location. It is either an int or a tuple.
|
Chris@87
|
3604
|
Chris@87
|
3605 Notes
|
Chris@87
|
3606 -----
|
Chris@87
|
3607 Compared to indexing syntax, `itemset` provides some speed increase
|
Chris@87
|
3608 for placing a scalar into a particular location in an `ndarray`,
|
Chris@87
|
3609 if you must do this. However, generally this is discouraged:
|
Chris@87
|
3610 among other problems, it complicates the appearance of the code.
|
Chris@87
|
3611 Also, when using `itemset` (and `item`) inside a loop, be sure
|
Chris@87
|
3612 to assign the methods to a local variable to avoid the attribute
|
Chris@87
|
3613 look-up at each loop iteration.
|
Chris@87
|
3614
|
Chris@87
|
3615 Examples
|
Chris@87
|
3616 --------
|
Chris@87
|
3617 >>> x = np.random.randint(9, size=(3, 3))
|
Chris@87
|
3618 >>> x
|
Chris@87
|
3619 array([[3, 1, 7],
|
Chris@87
|
3620 [2, 8, 3],
|
Chris@87
|
3621 [8, 5, 3]])
|
Chris@87
|
3622 >>> x.itemset(4, 0)
|
Chris@87
|
3623 >>> x.itemset((2, 2), 9)
|
Chris@87
|
3624 >>> x
|
Chris@87
|
3625 array([[3, 1, 7],
|
Chris@87
|
3626 [2, 0, 3],
|
Chris@87
|
3627 [8, 5, 9]])
|
Chris@87
|
3628
|
Chris@87
|
3629 """))
|
Chris@87
|
3630
|
Chris@87
|
3631
|
Chris@87
|
3632 add_newdoc('numpy.core.multiarray', 'ndarray', ('setasflat',
|
Chris@87
|
3633 """
|
Chris@87
|
3634 a.setasflat(arr)
|
Chris@87
|
3635
|
Chris@87
|
3636 Equivalent to a.flat = arr.flat, but is generally more efficient.
|
Chris@87
|
3637 This function does not check for overlap, so if ``arr`` and ``a``
|
Chris@87
|
3638 are viewing the same data with different strides, the results will
|
Chris@87
|
3639 be unpredictable.
|
Chris@87
|
3640
|
Chris@87
|
3641 Parameters
|
Chris@87
|
3642 ----------
|
Chris@87
|
3643 arr : array_like
|
Chris@87
|
3644 The array to copy into a.
|
Chris@87
|
3645
|
Chris@87
|
3646 Examples
|
Chris@87
|
3647 --------
|
Chris@87
|
3648 >>> a = np.arange(2*4).reshape(2,4)[:,:-1]; a
|
Chris@87
|
3649 array([[0, 1, 2],
|
Chris@87
|
3650 [4, 5, 6]])
|
Chris@87
|
3651 >>> b = np.arange(3*3, dtype='f4').reshape(3,3).T[::-1,:-1]; b
|
Chris@87
|
3652 array([[ 2., 5.],
|
Chris@87
|
3653 [ 1., 4.],
|
Chris@87
|
3654 [ 0., 3.]], dtype=float32)
|
Chris@87
|
3655 >>> a.setasflat(b)
|
Chris@87
|
3656 >>> a
|
Chris@87
|
3657 array([[2, 5, 1],
|
Chris@87
|
3658 [4, 0, 3]])
|
Chris@87
|
3659
|
Chris@87
|
3660 """))
|
Chris@87
|
3661
|
Chris@87
|
3662
|
Chris@87
|
3663 add_newdoc('numpy.core.multiarray', 'ndarray', ('max',
|
Chris@87
|
3664 """
|
Chris@87
|
3665 a.max(axis=None, out=None)
|
Chris@87
|
3666
|
Chris@87
|
3667 Return the maximum along a given axis.
|
Chris@87
|
3668
|
Chris@87
|
3669 Refer to `numpy.amax` for full documentation.
|
Chris@87
|
3670
|
Chris@87
|
3671 See Also
|
Chris@87
|
3672 --------
|
Chris@87
|
3673 numpy.amax : equivalent function
|
Chris@87
|
3674
|
Chris@87
|
3675 """))
|
Chris@87
|
3676
|
Chris@87
|
3677
|
Chris@87
|
3678 add_newdoc('numpy.core.multiarray', 'ndarray', ('mean',
|
Chris@87
|
3679 """
|
Chris@87
|
3680 a.mean(axis=None, dtype=None, out=None)
|
Chris@87
|
3681
|
Chris@87
|
3682 Returns the average of the array elements along given axis.
|
Chris@87
|
3683
|
Chris@87
|
3684 Refer to `numpy.mean` for full documentation.
|
Chris@87
|
3685
|
Chris@87
|
3686 See Also
|
Chris@87
|
3687 --------
|
Chris@87
|
3688 numpy.mean : equivalent function
|
Chris@87
|
3689
|
Chris@87
|
3690 """))
|
Chris@87
|
3691
|
Chris@87
|
3692
|
Chris@87
|
3693 add_newdoc('numpy.core.multiarray', 'ndarray', ('min',
|
Chris@87
|
3694 """
|
Chris@87
|
3695 a.min(axis=None, out=None)
|
Chris@87
|
3696
|
Chris@87
|
3697 Return the minimum along a given axis.
|
Chris@87
|
3698
|
Chris@87
|
3699 Refer to `numpy.amin` for full documentation.
|
Chris@87
|
3700
|
Chris@87
|
3701 See Also
|
Chris@87
|
3702 --------
|
Chris@87
|
3703 numpy.amin : equivalent function
|
Chris@87
|
3704
|
Chris@87
|
3705 """))
|
Chris@87
|
3706
|
Chris@87
|
3707
|
Chris@87
|
3708 add_newdoc('numpy.core.multiarray', 'may_share_memory',
|
Chris@87
|
3709 """
|
Chris@87
|
3710 Determine if two arrays can share memory
|
Chris@87
|
3711
|
Chris@87
|
3712 The memory-bounds of a and b are computed. If they overlap then
|
Chris@87
|
3713 this function returns True. Otherwise, it returns False.
|
Chris@87
|
3714
|
Chris@87
|
3715 A return of True does not necessarily mean that the two arrays
|
Chris@87
|
3716 share any element. It just means that they *might*.
|
Chris@87
|
3717
|
Chris@87
|
3718 Parameters
|
Chris@87
|
3719 ----------
|
Chris@87
|
3720 a, b : ndarray
|
Chris@87
|
3721
|
Chris@87
|
3722 Returns
|
Chris@87
|
3723 -------
|
Chris@87
|
3724 out : bool
|
Chris@87
|
3725
|
Chris@87
|
3726 Examples
|
Chris@87
|
3727 --------
|
Chris@87
|
3728 >>> np.may_share_memory(np.array([1,2]), np.array([5,8,9]))
|
Chris@87
|
3729 False
|
Chris@87
|
3730
|
Chris@87
|
3731 """)
|
Chris@87
|
3732
|
Chris@87
|
3733
|
Chris@87
|
3734 add_newdoc('numpy.core.multiarray', 'ndarray', ('newbyteorder',
|
Chris@87
|
3735 """
|
Chris@87
|
3736 arr.newbyteorder(new_order='S')
|
Chris@87
|
3737
|
Chris@87
|
3738 Return the array with the same data viewed with a different byte order.
|
Chris@87
|
3739
|
Chris@87
|
3740 Equivalent to::
|
Chris@87
|
3741
|
Chris@87
|
3742 arr.view(arr.dtype.newbytorder(new_order))
|
Chris@87
|
3743
|
Chris@87
|
3744 Changes are also made in all fields and sub-arrays of the array data
|
Chris@87
|
3745 type.
|
Chris@87
|
3746
|
Chris@87
|
3747
|
Chris@87
|
3748
|
Chris@87
|
3749 Parameters
|
Chris@87
|
3750 ----------
|
Chris@87
|
3751 new_order : string, optional
|
Chris@87
|
3752 Byte order to force; a value from the byte order specifications
|
Chris@87
|
3753 above. `new_order` codes can be any of::
|
Chris@87
|
3754
|
Chris@87
|
3755 * 'S' - swap dtype from current to opposite endian
|
Chris@87
|
3756 * {'<', 'L'} - little endian
|
Chris@87
|
3757 * {'>', 'B'} - big endian
|
Chris@87
|
3758 * {'=', 'N'} - native order
|
Chris@87
|
3759 * {'|', 'I'} - ignore (no change to byte order)
|
Chris@87
|
3760
|
Chris@87
|
3761 The default value ('S') results in swapping the current
|
Chris@87
|
3762 byte order. The code does a case-insensitive check on the first
|
Chris@87
|
3763 letter of `new_order` for the alternatives above. For example,
|
Chris@87
|
3764 any of 'B' or 'b' or 'biggish' are valid to specify big-endian.
|
Chris@87
|
3765
|
Chris@87
|
3766
|
Chris@87
|
3767 Returns
|
Chris@87
|
3768 -------
|
Chris@87
|
3769 new_arr : array
|
Chris@87
|
3770 New array object with the dtype reflecting given change to the
|
Chris@87
|
3771 byte order.
|
Chris@87
|
3772
|
Chris@87
|
3773 """))
|
Chris@87
|
3774
|
Chris@87
|
3775
|
Chris@87
|
3776 add_newdoc('numpy.core.multiarray', 'ndarray', ('nonzero',
|
Chris@87
|
3777 """
|
Chris@87
|
3778 a.nonzero()
|
Chris@87
|
3779
|
Chris@87
|
3780 Return the indices of the elements that are non-zero.
|
Chris@87
|
3781
|
Chris@87
|
3782 Refer to `numpy.nonzero` for full documentation.
|
Chris@87
|
3783
|
Chris@87
|
3784 See Also
|
Chris@87
|
3785 --------
|
Chris@87
|
3786 numpy.nonzero : equivalent function
|
Chris@87
|
3787
|
Chris@87
|
3788 """))
|
Chris@87
|
3789
|
Chris@87
|
3790
|
Chris@87
|
3791 add_newdoc('numpy.core.multiarray', 'ndarray', ('prod',
|
Chris@87
|
3792 """
|
Chris@87
|
3793 a.prod(axis=None, dtype=None, out=None)
|
Chris@87
|
3794
|
Chris@87
|
3795 Return the product of the array elements over the given axis
|
Chris@87
|
3796
|
Chris@87
|
3797 Refer to `numpy.prod` for full documentation.
|
Chris@87
|
3798
|
Chris@87
|
3799 See Also
|
Chris@87
|
3800 --------
|
Chris@87
|
3801 numpy.prod : equivalent function
|
Chris@87
|
3802
|
Chris@87
|
3803 """))
|
Chris@87
|
3804
|
Chris@87
|
3805
|
Chris@87
|
3806 add_newdoc('numpy.core.multiarray', 'ndarray', ('ptp',
|
Chris@87
|
3807 """
|
Chris@87
|
3808 a.ptp(axis=None, out=None)
|
Chris@87
|
3809
|
Chris@87
|
3810 Peak to peak (maximum - minimum) value along a given axis.
|
Chris@87
|
3811
|
Chris@87
|
3812 Refer to `numpy.ptp` for full documentation.
|
Chris@87
|
3813
|
Chris@87
|
3814 See Also
|
Chris@87
|
3815 --------
|
Chris@87
|
3816 numpy.ptp : equivalent function
|
Chris@87
|
3817
|
Chris@87
|
3818 """))
|
Chris@87
|
3819
|
Chris@87
|
3820
|
Chris@87
|
3821 add_newdoc('numpy.core.multiarray', 'ndarray', ('put',
|
Chris@87
|
3822 """
|
Chris@87
|
3823 a.put(indices, values, mode='raise')
|
Chris@87
|
3824
|
Chris@87
|
3825 Set ``a.flat[n] = values[n]`` for all `n` in indices.
|
Chris@87
|
3826
|
Chris@87
|
3827 Refer to `numpy.put` for full documentation.
|
Chris@87
|
3828
|
Chris@87
|
3829 See Also
|
Chris@87
|
3830 --------
|
Chris@87
|
3831 numpy.put : equivalent function
|
Chris@87
|
3832
|
Chris@87
|
3833 """))
|
Chris@87
|
3834
|
Chris@87
|
3835 add_newdoc('numpy.core.multiarray', 'copyto',
|
Chris@87
|
3836 """
|
Chris@87
|
3837 copyto(dst, src, casting='same_kind', where=None)
|
Chris@87
|
3838
|
Chris@87
|
3839 Copies values from one array to another, broadcasting as necessary.
|
Chris@87
|
3840
|
Chris@87
|
3841 Raises a TypeError if the `casting` rule is violated, and if
|
Chris@87
|
3842 `where` is provided, it selects which elements to copy.
|
Chris@87
|
3843
|
Chris@87
|
3844 .. versionadded:: 1.7.0
|
Chris@87
|
3845
|
Chris@87
|
3846 Parameters
|
Chris@87
|
3847 ----------
|
Chris@87
|
3848 dst : ndarray
|
Chris@87
|
3849 The array into which values are copied.
|
Chris@87
|
3850 src : array_like
|
Chris@87
|
3851 The array from which values are copied.
|
Chris@87
|
3852 casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
|
Chris@87
|
3853 Controls what kind of data casting may occur when copying.
|
Chris@87
|
3854
|
Chris@87
|
3855 * 'no' means the data types should not be cast at all.
|
Chris@87
|
3856 * 'equiv' means only byte-order changes are allowed.
|
Chris@87
|
3857 * 'safe' means only casts which can preserve values are allowed.
|
Chris@87
|
3858 * 'same_kind' means only safe casts or casts within a kind,
|
Chris@87
|
3859 like float64 to float32, are allowed.
|
Chris@87
|
3860 * 'unsafe' means any data conversions may be done.
|
Chris@87
|
3861 where : array_like of bool, optional
|
Chris@87
|
3862 A boolean array which is broadcasted to match the dimensions
|
Chris@87
|
3863 of `dst`, and selects elements to copy from `src` to `dst`
|
Chris@87
|
3864 wherever it contains the value True.
|
Chris@87
|
3865
|
Chris@87
|
3866 """)
|
Chris@87
|
3867
|
Chris@87
|
3868 add_newdoc('numpy.core.multiarray', 'putmask',
|
Chris@87
|
3869 """
|
Chris@87
|
3870 putmask(a, mask, values)
|
Chris@87
|
3871
|
Chris@87
|
3872 Changes elements of an array based on conditional and input values.
|
Chris@87
|
3873
|
Chris@87
|
3874 Sets ``a.flat[n] = values[n]`` for each n where ``mask.flat[n]==True``.
|
Chris@87
|
3875
|
Chris@87
|
3876 If `values` is not the same size as `a` and `mask` then it will repeat.
|
Chris@87
|
3877 This gives behavior different from ``a[mask] = values``.
|
Chris@87
|
3878
|
Chris@87
|
3879 Parameters
|
Chris@87
|
3880 ----------
|
Chris@87
|
3881 a : array_like
|
Chris@87
|
3882 Target array.
|
Chris@87
|
3883 mask : array_like
|
Chris@87
|
3884 Boolean mask array. It has to be the same shape as `a`.
|
Chris@87
|
3885 values : array_like
|
Chris@87
|
3886 Values to put into `a` where `mask` is True. If `values` is smaller
|
Chris@87
|
3887 than `a` it will be repeated.
|
Chris@87
|
3888
|
Chris@87
|
3889 See Also
|
Chris@87
|
3890 --------
|
Chris@87
|
3891 place, put, take, copyto
|
Chris@87
|
3892
|
Chris@87
|
3893 Examples
|
Chris@87
|
3894 --------
|
Chris@87
|
3895 >>> x = np.arange(6).reshape(2, 3)
|
Chris@87
|
3896 >>> np.putmask(x, x>2, x**2)
|
Chris@87
|
3897 >>> x
|
Chris@87
|
3898 array([[ 0, 1, 2],
|
Chris@87
|
3899 [ 9, 16, 25]])
|
Chris@87
|
3900
|
Chris@87
|
3901 If `values` is smaller than `a` it is repeated:
|
Chris@87
|
3902
|
Chris@87
|
3903 >>> x = np.arange(5)
|
Chris@87
|
3904 >>> np.putmask(x, x>1, [-33, -44])
|
Chris@87
|
3905 >>> x
|
Chris@87
|
3906 array([ 0, 1, -33, -44, -33])
|
Chris@87
|
3907
|
Chris@87
|
3908 """)
|
Chris@87
|
3909
|
Chris@87
|
3910
|
Chris@87
|
3911 add_newdoc('numpy.core.multiarray', 'ndarray', ('ravel',
|
Chris@87
|
3912 """
|
Chris@87
|
3913 a.ravel([order])
|
Chris@87
|
3914
|
Chris@87
|
3915 Return a flattened array.
|
Chris@87
|
3916
|
Chris@87
|
3917 Refer to `numpy.ravel` for full documentation.
|
Chris@87
|
3918
|
Chris@87
|
3919 See Also
|
Chris@87
|
3920 --------
|
Chris@87
|
3921 numpy.ravel : equivalent function
|
Chris@87
|
3922
|
Chris@87
|
3923 ndarray.flat : a flat iterator on the array.
|
Chris@87
|
3924
|
Chris@87
|
3925 """))
|
Chris@87
|
3926
|
Chris@87
|
3927
|
Chris@87
|
3928 add_newdoc('numpy.core.multiarray', 'ndarray', ('repeat',
|
Chris@87
|
3929 """
|
Chris@87
|
3930 a.repeat(repeats, axis=None)
|
Chris@87
|
3931
|
Chris@87
|
3932 Repeat elements of an array.
|
Chris@87
|
3933
|
Chris@87
|
3934 Refer to `numpy.repeat` for full documentation.
|
Chris@87
|
3935
|
Chris@87
|
3936 See Also
|
Chris@87
|
3937 --------
|
Chris@87
|
3938 numpy.repeat : equivalent function
|
Chris@87
|
3939
|
Chris@87
|
3940 """))
|
Chris@87
|
3941
|
Chris@87
|
3942
|
Chris@87
|
3943 add_newdoc('numpy.core.multiarray', 'ndarray', ('reshape',
|
Chris@87
|
3944 """
|
Chris@87
|
3945 a.reshape(shape, order='C')
|
Chris@87
|
3946
|
Chris@87
|
3947 Returns an array containing the same data with a new shape.
|
Chris@87
|
3948
|
Chris@87
|
3949 Refer to `numpy.reshape` for full documentation.
|
Chris@87
|
3950
|
Chris@87
|
3951 See Also
|
Chris@87
|
3952 --------
|
Chris@87
|
3953 numpy.reshape : equivalent function
|
Chris@87
|
3954
|
Chris@87
|
3955 """))
|
Chris@87
|
3956
|
Chris@87
|
3957
|
Chris@87
|
3958 add_newdoc('numpy.core.multiarray', 'ndarray', ('resize',
|
Chris@87
|
3959 """
|
Chris@87
|
3960 a.resize(new_shape, refcheck=True)
|
Chris@87
|
3961
|
Chris@87
|
3962 Change shape and size of array in-place.
|
Chris@87
|
3963
|
Chris@87
|
3964 Parameters
|
Chris@87
|
3965 ----------
|
Chris@87
|
3966 new_shape : tuple of ints, or `n` ints
|
Chris@87
|
3967 Shape of resized array.
|
Chris@87
|
3968 refcheck : bool, optional
|
Chris@87
|
3969 If False, reference count will not be checked. Default is True.
|
Chris@87
|
3970
|
Chris@87
|
3971 Returns
|
Chris@87
|
3972 -------
|
Chris@87
|
3973 None
|
Chris@87
|
3974
|
Chris@87
|
3975 Raises
|
Chris@87
|
3976 ------
|
Chris@87
|
3977 ValueError
|
Chris@87
|
3978 If `a` does not own its own data or references or views to it exist,
|
Chris@87
|
3979 and the data memory must be changed.
|
Chris@87
|
3980
|
Chris@87
|
3981 SystemError
|
Chris@87
|
3982 If the `order` keyword argument is specified. This behaviour is a
|
Chris@87
|
3983 bug in NumPy.
|
Chris@87
|
3984
|
Chris@87
|
3985 See Also
|
Chris@87
|
3986 --------
|
Chris@87
|
3987 resize : Return a new array with the specified shape.
|
Chris@87
|
3988
|
Chris@87
|
3989 Notes
|
Chris@87
|
3990 -----
|
Chris@87
|
3991 This reallocates space for the data area if necessary.
|
Chris@87
|
3992
|
Chris@87
|
3993 Only contiguous arrays (data elements consecutive in memory) can be
|
Chris@87
|
3994 resized.
|
Chris@87
|
3995
|
Chris@87
|
3996 The purpose of the reference count check is to make sure you
|
Chris@87
|
3997 do not use this array as a buffer for another Python object and then
|
Chris@87
|
3998 reallocate the memory. However, reference counts can increase in
|
Chris@87
|
3999 other ways so if you are sure that you have not shared the memory
|
Chris@87
|
4000 for this array with another Python object, then you may safely set
|
Chris@87
|
4001 `refcheck` to False.
|
Chris@87
|
4002
|
Chris@87
|
4003 Examples
|
Chris@87
|
4004 --------
|
Chris@87
|
4005 Shrinking an array: array is flattened (in the order that the data are
|
Chris@87
|
4006 stored in memory), resized, and reshaped:
|
Chris@87
|
4007
|
Chris@87
|
4008 >>> a = np.array([[0, 1], [2, 3]], order='C')
|
Chris@87
|
4009 >>> a.resize((2, 1))
|
Chris@87
|
4010 >>> a
|
Chris@87
|
4011 array([[0],
|
Chris@87
|
4012 [1]])
|
Chris@87
|
4013
|
Chris@87
|
4014 >>> a = np.array([[0, 1], [2, 3]], order='F')
|
Chris@87
|
4015 >>> a.resize((2, 1))
|
Chris@87
|
4016 >>> a
|
Chris@87
|
4017 array([[0],
|
Chris@87
|
4018 [2]])
|
Chris@87
|
4019
|
Chris@87
|
4020 Enlarging an array: as above, but missing entries are filled with zeros:
|
Chris@87
|
4021
|
Chris@87
|
4022 >>> b = np.array([[0, 1], [2, 3]])
|
Chris@87
|
4023 >>> b.resize(2, 3) # new_shape parameter doesn't have to be a tuple
|
Chris@87
|
4024 >>> b
|
Chris@87
|
4025 array([[0, 1, 2],
|
Chris@87
|
4026 [3, 0, 0]])
|
Chris@87
|
4027
|
Chris@87
|
4028 Referencing an array prevents resizing...
|
Chris@87
|
4029
|
Chris@87
|
4030 >>> c = a
|
Chris@87
|
4031 >>> a.resize((1, 1))
|
Chris@87
|
4032 Traceback (most recent call last):
|
Chris@87
|
4033 ...
|
Chris@87
|
4034 ValueError: cannot resize an array that has been referenced ...
|
Chris@87
|
4035
|
Chris@87
|
4036 Unless `refcheck` is False:
|
Chris@87
|
4037
|
Chris@87
|
4038 >>> a.resize((1, 1), refcheck=False)
|
Chris@87
|
4039 >>> a
|
Chris@87
|
4040 array([[0]])
|
Chris@87
|
4041 >>> c
|
Chris@87
|
4042 array([[0]])
|
Chris@87
|
4043
|
Chris@87
|
4044 """))
|
Chris@87
|
4045
|
Chris@87
|
4046
|
Chris@87
|
4047 add_newdoc('numpy.core.multiarray', 'ndarray', ('round',
|
Chris@87
|
4048 """
|
Chris@87
|
4049 a.round(decimals=0, out=None)
|
Chris@87
|
4050
|
Chris@87
|
4051 Return `a` with each element rounded to the given number of decimals.
|
Chris@87
|
4052
|
Chris@87
|
4053 Refer to `numpy.around` for full documentation.
|
Chris@87
|
4054
|
Chris@87
|
4055 See Also
|
Chris@87
|
4056 --------
|
Chris@87
|
4057 numpy.around : equivalent function
|
Chris@87
|
4058
|
Chris@87
|
4059 """))
|
Chris@87
|
4060
|
Chris@87
|
4061
|
Chris@87
|
4062 add_newdoc('numpy.core.multiarray', 'ndarray', ('searchsorted',
|
Chris@87
|
4063 """
|
Chris@87
|
4064 a.searchsorted(v, side='left', sorter=None)
|
Chris@87
|
4065
|
Chris@87
|
4066 Find indices where elements of v should be inserted in a to maintain order.
|
Chris@87
|
4067
|
Chris@87
|
4068 For full documentation, see `numpy.searchsorted`
|
Chris@87
|
4069
|
Chris@87
|
4070 See Also
|
Chris@87
|
4071 --------
|
Chris@87
|
4072 numpy.searchsorted : equivalent function
|
Chris@87
|
4073
|
Chris@87
|
4074 """))
|
Chris@87
|
4075
|
Chris@87
|
4076
|
Chris@87
|
4077 add_newdoc('numpy.core.multiarray', 'ndarray', ('setfield',
|
Chris@87
|
4078 """
|
Chris@87
|
4079 a.setfield(val, dtype, offset=0)
|
Chris@87
|
4080
|
Chris@87
|
4081 Put a value into a specified place in a field defined by a data-type.
|
Chris@87
|
4082
|
Chris@87
|
4083 Place `val` into `a`'s field defined by `dtype` and beginning `offset`
|
Chris@87
|
4084 bytes into the field.
|
Chris@87
|
4085
|
Chris@87
|
4086 Parameters
|
Chris@87
|
4087 ----------
|
Chris@87
|
4088 val : object
|
Chris@87
|
4089 Value to be placed in field.
|
Chris@87
|
4090 dtype : dtype object
|
Chris@87
|
4091 Data-type of the field in which to place `val`.
|
Chris@87
|
4092 offset : int, optional
|
Chris@87
|
4093 The number of bytes into the field at which to place `val`.
|
Chris@87
|
4094
|
Chris@87
|
4095 Returns
|
Chris@87
|
4096 -------
|
Chris@87
|
4097 None
|
Chris@87
|
4098
|
Chris@87
|
4099 See Also
|
Chris@87
|
4100 --------
|
Chris@87
|
4101 getfield
|
Chris@87
|
4102
|
Chris@87
|
4103 Examples
|
Chris@87
|
4104 --------
|
Chris@87
|
4105 >>> x = np.eye(3)
|
Chris@87
|
4106 >>> x.getfield(np.float64)
|
Chris@87
|
4107 array([[ 1., 0., 0.],
|
Chris@87
|
4108 [ 0., 1., 0.],
|
Chris@87
|
4109 [ 0., 0., 1.]])
|
Chris@87
|
4110 >>> x.setfield(3, np.int32)
|
Chris@87
|
4111 >>> x.getfield(np.int32)
|
Chris@87
|
4112 array([[3, 3, 3],
|
Chris@87
|
4113 [3, 3, 3],
|
Chris@87
|
4114 [3, 3, 3]])
|
Chris@87
|
4115 >>> x
|
Chris@87
|
4116 array([[ 1.00000000e+000, 1.48219694e-323, 1.48219694e-323],
|
Chris@87
|
4117 [ 1.48219694e-323, 1.00000000e+000, 1.48219694e-323],
|
Chris@87
|
4118 [ 1.48219694e-323, 1.48219694e-323, 1.00000000e+000]])
|
Chris@87
|
4119 >>> x.setfield(np.eye(3), np.int32)
|
Chris@87
|
4120 >>> x
|
Chris@87
|
4121 array([[ 1., 0., 0.],
|
Chris@87
|
4122 [ 0., 1., 0.],
|
Chris@87
|
4123 [ 0., 0., 1.]])
|
Chris@87
|
4124
|
Chris@87
|
4125 """))
|
Chris@87
|
4126
|
Chris@87
|
4127
|
Chris@87
|
4128 add_newdoc('numpy.core.multiarray', 'ndarray', ('setflags',
|
Chris@87
|
4129 """
|
Chris@87
|
4130 a.setflags(write=None, align=None, uic=None)
|
Chris@87
|
4131
|
Chris@87
|
4132 Set array flags WRITEABLE, ALIGNED, and UPDATEIFCOPY, respectively.
|
Chris@87
|
4133
|
Chris@87
|
4134 These Boolean-valued flags affect how numpy interprets the memory
|
Chris@87
|
4135 area used by `a` (see Notes below). The ALIGNED flag can only
|
Chris@87
|
4136 be set to True if the data is actually aligned according to the type.
|
Chris@87
|
4137 The UPDATEIFCOPY flag can never be set to True. The flag WRITEABLE
|
Chris@87
|
4138 can only be set to True if the array owns its own memory, or the
|
Chris@87
|
4139 ultimate owner of the memory exposes a writeable buffer interface,
|
Chris@87
|
4140 or is a string. (The exception for string is made so that unpickling
|
Chris@87
|
4141 can be done without copying memory.)
|
Chris@87
|
4142
|
Chris@87
|
4143 Parameters
|
Chris@87
|
4144 ----------
|
Chris@87
|
4145 write : bool, optional
|
Chris@87
|
4146 Describes whether or not `a` can be written to.
|
Chris@87
|
4147 align : bool, optional
|
Chris@87
|
4148 Describes whether or not `a` is aligned properly for its type.
|
Chris@87
|
4149 uic : bool, optional
|
Chris@87
|
4150 Describes whether or not `a` is a copy of another "base" array.
|
Chris@87
|
4151
|
Chris@87
|
4152 Notes
|
Chris@87
|
4153 -----
|
Chris@87
|
4154 Array flags provide information about how the memory area used
|
Chris@87
|
4155 for the array is to be interpreted. There are 6 Boolean flags
|
Chris@87
|
4156 in use, only three of which can be changed by the user:
|
Chris@87
|
4157 UPDATEIFCOPY, WRITEABLE, and ALIGNED.
|
Chris@87
|
4158
|
Chris@87
|
4159 WRITEABLE (W) the data area can be written to;
|
Chris@87
|
4160
|
Chris@87
|
4161 ALIGNED (A) the data and strides are aligned appropriately for the hardware
|
Chris@87
|
4162 (as determined by the compiler);
|
Chris@87
|
4163
|
Chris@87
|
4164 UPDATEIFCOPY (U) this array is a copy of some other array (referenced
|
Chris@87
|
4165 by .base). When this array is deallocated, the base array will be
|
Chris@87
|
4166 updated with the contents of this array.
|
Chris@87
|
4167
|
Chris@87
|
4168 All flags can be accessed using their first (upper case) letter as well
|
Chris@87
|
4169 as the full name.
|
Chris@87
|
4170
|
Chris@87
|
4171 Examples
|
Chris@87
|
4172 --------
|
Chris@87
|
4173 >>> y
|
Chris@87
|
4174 array([[3, 1, 7],
|
Chris@87
|
4175 [2, 0, 0],
|
Chris@87
|
4176 [8, 5, 9]])
|
Chris@87
|
4177 >>> y.flags
|
Chris@87
|
4178 C_CONTIGUOUS : True
|
Chris@87
|
4179 F_CONTIGUOUS : False
|
Chris@87
|
4180 OWNDATA : True
|
Chris@87
|
4181 WRITEABLE : True
|
Chris@87
|
4182 ALIGNED : True
|
Chris@87
|
4183 UPDATEIFCOPY : False
|
Chris@87
|
4184 >>> y.setflags(write=0, align=0)
|
Chris@87
|
4185 >>> y.flags
|
Chris@87
|
4186 C_CONTIGUOUS : True
|
Chris@87
|
4187 F_CONTIGUOUS : False
|
Chris@87
|
4188 OWNDATA : True
|
Chris@87
|
4189 WRITEABLE : False
|
Chris@87
|
4190 ALIGNED : False
|
Chris@87
|
4191 UPDATEIFCOPY : False
|
Chris@87
|
4192 >>> y.setflags(uic=1)
|
Chris@87
|
4193 Traceback (most recent call last):
|
Chris@87
|
4194 File "<stdin>", line 1, in <module>
|
Chris@87
|
4195 ValueError: cannot set UPDATEIFCOPY flag to True
|
Chris@87
|
4196
|
Chris@87
|
4197 """))
|
Chris@87
|
4198
|
Chris@87
|
4199
|
Chris@87
|
4200 add_newdoc('numpy.core.multiarray', 'ndarray', ('sort',
|
Chris@87
|
4201 """
|
Chris@87
|
4202 a.sort(axis=-1, kind='quicksort', order=None)
|
Chris@87
|
4203
|
Chris@87
|
4204 Sort an array, in-place.
|
Chris@87
|
4205
|
Chris@87
|
4206 Parameters
|
Chris@87
|
4207 ----------
|
Chris@87
|
4208 axis : int, optional
|
Chris@87
|
4209 Axis along which to sort. Default is -1, which means sort along the
|
Chris@87
|
4210 last axis.
|
Chris@87
|
4211 kind : {'quicksort', 'mergesort', 'heapsort'}, optional
|
Chris@87
|
4212 Sorting algorithm. Default is 'quicksort'.
|
Chris@87
|
4213 order : list, optional
|
Chris@87
|
4214 When `a` is an array with fields defined, this argument specifies
|
Chris@87
|
4215 which fields to compare first, second, etc. Not all fields need be
|
Chris@87
|
4216 specified.
|
Chris@87
|
4217
|
Chris@87
|
4218 See Also
|
Chris@87
|
4219 --------
|
Chris@87
|
4220 numpy.sort : Return a sorted copy of an array.
|
Chris@87
|
4221 argsort : Indirect sort.
|
Chris@87
|
4222 lexsort : Indirect stable sort on multiple keys.
|
Chris@87
|
4223 searchsorted : Find elements in sorted array.
|
Chris@87
|
4224 partition: Partial sort.
|
Chris@87
|
4225
|
Chris@87
|
4226 Notes
|
Chris@87
|
4227 -----
|
Chris@87
|
4228 See ``sort`` for notes on the different sorting algorithms.
|
Chris@87
|
4229
|
Chris@87
|
4230 Examples
|
Chris@87
|
4231 --------
|
Chris@87
|
4232 >>> a = np.array([[1,4], [3,1]])
|
Chris@87
|
4233 >>> a.sort(axis=1)
|
Chris@87
|
4234 >>> a
|
Chris@87
|
4235 array([[1, 4],
|
Chris@87
|
4236 [1, 3]])
|
Chris@87
|
4237 >>> a.sort(axis=0)
|
Chris@87
|
4238 >>> a
|
Chris@87
|
4239 array([[1, 3],
|
Chris@87
|
4240 [1, 4]])
|
Chris@87
|
4241
|
Chris@87
|
4242 Use the `order` keyword to specify a field to use when sorting a
|
Chris@87
|
4243 structured array:
|
Chris@87
|
4244
|
Chris@87
|
4245 >>> a = np.array([('a', 2), ('c', 1)], dtype=[('x', 'S1'), ('y', int)])
|
Chris@87
|
4246 >>> a.sort(order='y')
|
Chris@87
|
4247 >>> a
|
Chris@87
|
4248 array([('c', 1), ('a', 2)],
|
Chris@87
|
4249 dtype=[('x', '|S1'), ('y', '<i4')])
|
Chris@87
|
4250
|
Chris@87
|
4251 """))
|
Chris@87
|
4252
|
Chris@87
|
4253
|
Chris@87
|
4254 add_newdoc('numpy.core.multiarray', 'ndarray', ('partition',
|
Chris@87
|
4255 """
|
Chris@87
|
4256 a.partition(kth, axis=-1, kind='introselect', order=None)
|
Chris@87
|
4257
|
Chris@87
|
4258 Rearranges the elements in the array in such a way that value of the
|
Chris@87
|
4259 element in kth position is in the position it would be in a sorted array.
|
Chris@87
|
4260 All elements smaller than the kth element are moved before this element and
|
Chris@87
|
4261 all equal or greater are moved behind it. The ordering of the elements in
|
Chris@87
|
4262 the two partitions is undefined.
|
Chris@87
|
4263
|
Chris@87
|
4264 .. versionadded:: 1.8.0
|
Chris@87
|
4265
|
Chris@87
|
4266 Parameters
|
Chris@87
|
4267 ----------
|
Chris@87
|
4268 kth : int or sequence of ints
|
Chris@87
|
4269 Element index to partition by. The kth element value will be in its
|
Chris@87
|
4270 final sorted position and all smaller elements will be moved before it
|
Chris@87
|
4271 and all equal or greater elements behind it.
|
Chris@87
|
4272 The order all elements in the partitions is undefined.
|
Chris@87
|
4273 If provided with a sequence of kth it will partition all elements
|
Chris@87
|
4274 indexed by kth of them into their sorted position at once.
|
Chris@87
|
4275 axis : int, optional
|
Chris@87
|
4276 Axis along which to sort. Default is -1, which means sort along the
|
Chris@87
|
4277 last axis.
|
Chris@87
|
4278 kind : {'introselect'}, optional
|
Chris@87
|
4279 Selection algorithm. Default is 'introselect'.
|
Chris@87
|
4280 order : list, optional
|
Chris@87
|
4281 When `a` is an array with fields defined, this argument specifies
|
Chris@87
|
4282 which fields to compare first, second, etc. Not all fields need be
|
Chris@87
|
4283 specified.
|
Chris@87
|
4284
|
Chris@87
|
4285 See Also
|
Chris@87
|
4286 --------
|
Chris@87
|
4287 numpy.partition : Return a parititioned copy of an array.
|
Chris@87
|
4288 argpartition : Indirect partition.
|
Chris@87
|
4289 sort : Full sort.
|
Chris@87
|
4290
|
Chris@87
|
4291 Notes
|
Chris@87
|
4292 -----
|
Chris@87
|
4293 See ``np.partition`` for notes on the different algorithms.
|
Chris@87
|
4294
|
Chris@87
|
4295 Examples
|
Chris@87
|
4296 --------
|
Chris@87
|
4297 >>> a = np.array([3, 4, 2, 1])
|
Chris@87
|
4298 >>> a.partition(a, 3)
|
Chris@87
|
4299 >>> a
|
Chris@87
|
4300 array([2, 1, 3, 4])
|
Chris@87
|
4301
|
Chris@87
|
4302 >>> a.partition((1, 3))
|
Chris@87
|
4303 array([1, 2, 3, 4])
|
Chris@87
|
4304 """))
|
Chris@87
|
4305
|
Chris@87
|
4306
|
Chris@87
|
4307 add_newdoc('numpy.core.multiarray', 'ndarray', ('squeeze',
|
Chris@87
|
4308 """
|
Chris@87
|
4309 a.squeeze(axis=None)
|
Chris@87
|
4310
|
Chris@87
|
4311 Remove single-dimensional entries from the shape of `a`.
|
Chris@87
|
4312
|
Chris@87
|
4313 Refer to `numpy.squeeze` for full documentation.
|
Chris@87
|
4314
|
Chris@87
|
4315 See Also
|
Chris@87
|
4316 --------
|
Chris@87
|
4317 numpy.squeeze : equivalent function
|
Chris@87
|
4318
|
Chris@87
|
4319 """))
|
Chris@87
|
4320
|
Chris@87
|
4321
|
Chris@87
|
4322 add_newdoc('numpy.core.multiarray', 'ndarray', ('std',
|
Chris@87
|
4323 """
|
Chris@87
|
4324 a.std(axis=None, dtype=None, out=None, ddof=0)
|
Chris@87
|
4325
|
Chris@87
|
4326 Returns the standard deviation of the array elements along given axis.
|
Chris@87
|
4327
|
Chris@87
|
4328 Refer to `numpy.std` for full documentation.
|
Chris@87
|
4329
|
Chris@87
|
4330 See Also
|
Chris@87
|
4331 --------
|
Chris@87
|
4332 numpy.std : equivalent function
|
Chris@87
|
4333
|
Chris@87
|
4334 """))
|
Chris@87
|
4335
|
Chris@87
|
4336
|
Chris@87
|
4337 add_newdoc('numpy.core.multiarray', 'ndarray', ('sum',
|
Chris@87
|
4338 """
|
Chris@87
|
4339 a.sum(axis=None, dtype=None, out=None)
|
Chris@87
|
4340
|
Chris@87
|
4341 Return the sum of the array elements over the given axis.
|
Chris@87
|
4342
|
Chris@87
|
4343 Refer to `numpy.sum` for full documentation.
|
Chris@87
|
4344
|
Chris@87
|
4345 See Also
|
Chris@87
|
4346 --------
|
Chris@87
|
4347 numpy.sum : equivalent function
|
Chris@87
|
4348
|
Chris@87
|
4349 """))
|
Chris@87
|
4350
|
Chris@87
|
4351
|
Chris@87
|
4352 add_newdoc('numpy.core.multiarray', 'ndarray', ('swapaxes',
|
Chris@87
|
4353 """
|
Chris@87
|
4354 a.swapaxes(axis1, axis2)
|
Chris@87
|
4355
|
Chris@87
|
4356 Return a view of the array with `axis1` and `axis2` interchanged.
|
Chris@87
|
4357
|
Chris@87
|
4358 Refer to `numpy.swapaxes` for full documentation.
|
Chris@87
|
4359
|
Chris@87
|
4360 See Also
|
Chris@87
|
4361 --------
|
Chris@87
|
4362 numpy.swapaxes : equivalent function
|
Chris@87
|
4363
|
Chris@87
|
4364 """))
|
Chris@87
|
4365
|
Chris@87
|
4366
|
Chris@87
|
4367 add_newdoc('numpy.core.multiarray', 'ndarray', ('take',
|
Chris@87
|
4368 """
|
Chris@87
|
4369 a.take(indices, axis=None, out=None, mode='raise')
|
Chris@87
|
4370
|
Chris@87
|
4371 Return an array formed from the elements of `a` at the given indices.
|
Chris@87
|
4372
|
Chris@87
|
4373 Refer to `numpy.take` for full documentation.
|
Chris@87
|
4374
|
Chris@87
|
4375 See Also
|
Chris@87
|
4376 --------
|
Chris@87
|
4377 numpy.take : equivalent function
|
Chris@87
|
4378
|
Chris@87
|
4379 """))
|
Chris@87
|
4380
|
Chris@87
|
4381
|
Chris@87
|
4382 add_newdoc('numpy.core.multiarray', 'ndarray', ('tofile',
|
Chris@87
|
4383 """
|
Chris@87
|
4384 a.tofile(fid, sep="", format="%s")
|
Chris@87
|
4385
|
Chris@87
|
4386 Write array to a file as text or binary (default).
|
Chris@87
|
4387
|
Chris@87
|
4388 Data is always written in 'C' order, independent of the order of `a`.
|
Chris@87
|
4389 The data produced by this method can be recovered using the function
|
Chris@87
|
4390 fromfile().
|
Chris@87
|
4391
|
Chris@87
|
4392 Parameters
|
Chris@87
|
4393 ----------
|
Chris@87
|
4394 fid : file or str
|
Chris@87
|
4395 An open file object, or a string containing a filename.
|
Chris@87
|
4396 sep : str
|
Chris@87
|
4397 Separator between array items for text output.
|
Chris@87
|
4398 If "" (empty), a binary file is written, equivalent to
|
Chris@87
|
4399 ``file.write(a.tobytes())``.
|
Chris@87
|
4400 format : str
|
Chris@87
|
4401 Format string for text file output.
|
Chris@87
|
4402 Each entry in the array is formatted to text by first converting
|
Chris@87
|
4403 it to the closest Python type, and then using "format" % item.
|
Chris@87
|
4404
|
Chris@87
|
4405 Notes
|
Chris@87
|
4406 -----
|
Chris@87
|
4407 This is a convenience function for quick storage of array data.
|
Chris@87
|
4408 Information on endianness and precision is lost, so this method is not a
|
Chris@87
|
4409 good choice for files intended to archive data or transport data between
|
Chris@87
|
4410 machines with different endianness. Some of these problems can be overcome
|
Chris@87
|
4411 by outputting the data as text files, at the expense of speed and file
|
Chris@87
|
4412 size.
|
Chris@87
|
4413
|
Chris@87
|
4414 """))
|
Chris@87
|
4415
|
Chris@87
|
4416
|
Chris@87
|
4417 add_newdoc('numpy.core.multiarray', 'ndarray', ('tolist',
|
Chris@87
|
4418 """
|
Chris@87
|
4419 a.tolist()
|
Chris@87
|
4420
|
Chris@87
|
4421 Return the array as a (possibly nested) list.
|
Chris@87
|
4422
|
Chris@87
|
4423 Return a copy of the array data as a (nested) Python list.
|
Chris@87
|
4424 Data items are converted to the nearest compatible Python type.
|
Chris@87
|
4425
|
Chris@87
|
4426 Parameters
|
Chris@87
|
4427 ----------
|
Chris@87
|
4428 none
|
Chris@87
|
4429
|
Chris@87
|
4430 Returns
|
Chris@87
|
4431 -------
|
Chris@87
|
4432 y : list
|
Chris@87
|
4433 The possibly nested list of array elements.
|
Chris@87
|
4434
|
Chris@87
|
4435 Notes
|
Chris@87
|
4436 -----
|
Chris@87
|
4437 The array may be recreated, ``a = np.array(a.tolist())``.
|
Chris@87
|
4438
|
Chris@87
|
4439 Examples
|
Chris@87
|
4440 --------
|
Chris@87
|
4441 >>> a = np.array([1, 2])
|
Chris@87
|
4442 >>> a.tolist()
|
Chris@87
|
4443 [1, 2]
|
Chris@87
|
4444 >>> a = np.array([[1, 2], [3, 4]])
|
Chris@87
|
4445 >>> list(a)
|
Chris@87
|
4446 [array([1, 2]), array([3, 4])]
|
Chris@87
|
4447 >>> a.tolist()
|
Chris@87
|
4448 [[1, 2], [3, 4]]
|
Chris@87
|
4449
|
Chris@87
|
4450 """))
|
Chris@87
|
4451
|
Chris@87
|
4452
|
Chris@87
|
4453 tobytesdoc = """
|
Chris@87
|
4454 a.{name}(order='C')
|
Chris@87
|
4455
|
Chris@87
|
4456 Construct Python bytes containing the raw data bytes in the array.
|
Chris@87
|
4457
|
Chris@87
|
4458 Constructs Python bytes showing a copy of the raw contents of
|
Chris@87
|
4459 data memory. The bytes object can be produced in either 'C' or 'Fortran',
|
Chris@87
|
4460 or 'Any' order (the default is 'C'-order). 'Any' order means C-order
|
Chris@87
|
4461 unless the F_CONTIGUOUS flag in the array is set, in which case it
|
Chris@87
|
4462 means 'Fortran' order.
|
Chris@87
|
4463
|
Chris@87
|
4464 {deprecated}
|
Chris@87
|
4465
|
Chris@87
|
4466 Parameters
|
Chris@87
|
4467 ----------
|
Chris@87
|
4468 order : {{'C', 'F', None}}, optional
|
Chris@87
|
4469 Order of the data for multidimensional arrays:
|
Chris@87
|
4470 C, Fortran, or the same as for the original array.
|
Chris@87
|
4471
|
Chris@87
|
4472 Returns
|
Chris@87
|
4473 -------
|
Chris@87
|
4474 s : bytes
|
Chris@87
|
4475 Python bytes exhibiting a copy of `a`'s raw data.
|
Chris@87
|
4476
|
Chris@87
|
4477 Examples
|
Chris@87
|
4478 --------
|
Chris@87
|
4479 >>> x = np.array([[0, 1], [2, 3]])
|
Chris@87
|
4480 >>> x.tobytes()
|
Chris@87
|
4481 b'\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x03\\x00\\x00\\x00'
|
Chris@87
|
4482 >>> x.tobytes('C') == x.tobytes()
|
Chris@87
|
4483 True
|
Chris@87
|
4484 >>> x.tobytes('F')
|
Chris@87
|
4485 b'\\x00\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x03\\x00\\x00\\x00'
|
Chris@87
|
4486
|
Chris@87
|
4487 """
|
Chris@87
|
4488
|
Chris@87
|
4489 add_newdoc('numpy.core.multiarray', 'ndarray',
|
Chris@87
|
4490 ('tostring', tobytesdoc.format(name='tostring',
|
Chris@87
|
4491 deprecated=
|
Chris@87
|
4492 'This function is a compatibility '
|
Chris@87
|
4493 'alias for tobytes. Despite its '
|
Chris@87
|
4494 'name it returns bytes not '
|
Chris@87
|
4495 'strings.')))
|
Chris@87
|
4496 add_newdoc('numpy.core.multiarray', 'ndarray',
|
Chris@87
|
4497 ('tobytes', tobytesdoc.format(name='tobytes',
|
Chris@87
|
4498 deprecated='.. versionadded:: 1.9.0')))
|
Chris@87
|
4499
|
Chris@87
|
4500 add_newdoc('numpy.core.multiarray', 'ndarray', ('trace',
|
Chris@87
|
4501 """
|
Chris@87
|
4502 a.trace(offset=0, axis1=0, axis2=1, dtype=None, out=None)
|
Chris@87
|
4503
|
Chris@87
|
4504 Return the sum along diagonals of the array.
|
Chris@87
|
4505
|
Chris@87
|
4506 Refer to `numpy.trace` for full documentation.
|
Chris@87
|
4507
|
Chris@87
|
4508 See Also
|
Chris@87
|
4509 --------
|
Chris@87
|
4510 numpy.trace : equivalent function
|
Chris@87
|
4511
|
Chris@87
|
4512 """))
|
Chris@87
|
4513
|
Chris@87
|
4514
|
Chris@87
|
4515 add_newdoc('numpy.core.multiarray', 'ndarray', ('transpose',
|
Chris@87
|
4516 """
|
Chris@87
|
4517 a.transpose(*axes)
|
Chris@87
|
4518
|
Chris@87
|
4519 Returns a view of the array with axes transposed.
|
Chris@87
|
4520
|
Chris@87
|
4521 For a 1-D array, this has no effect. (To change between column and
|
Chris@87
|
4522 row vectors, first cast the 1-D array into a matrix object.)
|
Chris@87
|
4523 For a 2-D array, this is the usual matrix transpose.
|
Chris@87
|
4524 For an n-D array, if axes are given, their order indicates how the
|
Chris@87
|
4525 axes are permuted (see Examples). If axes are not provided and
|
Chris@87
|
4526 ``a.shape = (i[0], i[1], ... i[n-2], i[n-1])``, then
|
Chris@87
|
4527 ``a.transpose().shape = (i[n-1], i[n-2], ... i[1], i[0])``.
|
Chris@87
|
4528
|
Chris@87
|
4529 Parameters
|
Chris@87
|
4530 ----------
|
Chris@87
|
4531 axes : None, tuple of ints, or `n` ints
|
Chris@87
|
4532
|
Chris@87
|
4533 * None or no argument: reverses the order of the axes.
|
Chris@87
|
4534
|
Chris@87
|
4535 * tuple of ints: `i` in the `j`-th place in the tuple means `a`'s
|
Chris@87
|
4536 `i`-th axis becomes `a.transpose()`'s `j`-th axis.
|
Chris@87
|
4537
|
Chris@87
|
4538 * `n` ints: same as an n-tuple of the same ints (this form is
|
Chris@87
|
4539 intended simply as a "convenience" alternative to the tuple form)
|
Chris@87
|
4540
|
Chris@87
|
4541 Returns
|
Chris@87
|
4542 -------
|
Chris@87
|
4543 out : ndarray
|
Chris@87
|
4544 View of `a`, with axes suitably permuted.
|
Chris@87
|
4545
|
Chris@87
|
4546 See Also
|
Chris@87
|
4547 --------
|
Chris@87
|
4548 ndarray.T : Array property returning the array transposed.
|
Chris@87
|
4549
|
Chris@87
|
4550 Examples
|
Chris@87
|
4551 --------
|
Chris@87
|
4552 >>> a = np.array([[1, 2], [3, 4]])
|
Chris@87
|
4553 >>> a
|
Chris@87
|
4554 array([[1, 2],
|
Chris@87
|
4555 [3, 4]])
|
Chris@87
|
4556 >>> a.transpose()
|
Chris@87
|
4557 array([[1, 3],
|
Chris@87
|
4558 [2, 4]])
|
Chris@87
|
4559 >>> a.transpose((1, 0))
|
Chris@87
|
4560 array([[1, 3],
|
Chris@87
|
4561 [2, 4]])
|
Chris@87
|
4562 >>> a.transpose(1, 0)
|
Chris@87
|
4563 array([[1, 3],
|
Chris@87
|
4564 [2, 4]])
|
Chris@87
|
4565
|
Chris@87
|
4566 """))
|
Chris@87
|
4567
|
Chris@87
|
4568
|
Chris@87
|
4569 add_newdoc('numpy.core.multiarray', 'ndarray', ('var',
|
Chris@87
|
4570 """
|
Chris@87
|
4571 a.var(axis=None, dtype=None, out=None, ddof=0)
|
Chris@87
|
4572
|
Chris@87
|
4573 Returns the variance of the array elements, along given axis.
|
Chris@87
|
4574
|
Chris@87
|
4575 Refer to `numpy.var` for full documentation.
|
Chris@87
|
4576
|
Chris@87
|
4577 See Also
|
Chris@87
|
4578 --------
|
Chris@87
|
4579 numpy.var : equivalent function
|
Chris@87
|
4580
|
Chris@87
|
4581 """))
|
Chris@87
|
4582
|
Chris@87
|
4583
|
Chris@87
|
4584 add_newdoc('numpy.core.multiarray', 'ndarray', ('view',
|
Chris@87
|
4585 """
|
Chris@87
|
4586 a.view(dtype=None, type=None)
|
Chris@87
|
4587
|
Chris@87
|
4588 New view of array with the same data.
|
Chris@87
|
4589
|
Chris@87
|
4590 Parameters
|
Chris@87
|
4591 ----------
|
Chris@87
|
4592 dtype : data-type or ndarray sub-class, optional
|
Chris@87
|
4593 Data-type descriptor of the returned view, e.g., float32 or int16. The
|
Chris@87
|
4594 default, None, results in the view having the same data-type as `a`.
|
Chris@87
|
4595 This argument can also be specified as an ndarray sub-class, which
|
Chris@87
|
4596 then specifies the type of the returned object (this is equivalent to
|
Chris@87
|
4597 setting the ``type`` parameter).
|
Chris@87
|
4598 type : Python type, optional
|
Chris@87
|
4599 Type of the returned view, e.g., ndarray or matrix. Again, the
|
Chris@87
|
4600 default None results in type preservation.
|
Chris@87
|
4601
|
Chris@87
|
4602 Notes
|
Chris@87
|
4603 -----
|
Chris@87
|
4604 ``a.view()`` is used two different ways:
|
Chris@87
|
4605
|
Chris@87
|
4606 ``a.view(some_dtype)`` or ``a.view(dtype=some_dtype)`` constructs a view
|
Chris@87
|
4607 of the array's memory with a different data-type. This can cause a
|
Chris@87
|
4608 reinterpretation of the bytes of memory.
|
Chris@87
|
4609
|
Chris@87
|
4610 ``a.view(ndarray_subclass)`` or ``a.view(type=ndarray_subclass)`` just
|
Chris@87
|
4611 returns an instance of `ndarray_subclass` that looks at the same array
|
Chris@87
|
4612 (same shape, dtype, etc.) This does not cause a reinterpretation of the
|
Chris@87
|
4613 memory.
|
Chris@87
|
4614
|
Chris@87
|
4615 For ``a.view(some_dtype)``, if ``some_dtype`` has a different number of
|
Chris@87
|
4616 bytes per entry than the previous dtype (for example, converting a
|
Chris@87
|
4617 regular array to a structured array), then the behavior of the view
|
Chris@87
|
4618 cannot be predicted just from the superficial appearance of ``a`` (shown
|
Chris@87
|
4619 by ``print(a)``). It also depends on exactly how ``a`` is stored in
|
Chris@87
|
4620 memory. Therefore if ``a`` is C-ordered versus fortran-ordered, versus
|
Chris@87
|
4621 defined as a slice or transpose, etc., the view may give different
|
Chris@87
|
4622 results.
|
Chris@87
|
4623
|
Chris@87
|
4624
|
Chris@87
|
4625 Examples
|
Chris@87
|
4626 --------
|
Chris@87
|
4627 >>> x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])
|
Chris@87
|
4628
|
Chris@87
|
4629 Viewing array data using a different type and dtype:
|
Chris@87
|
4630
|
Chris@87
|
4631 >>> y = x.view(dtype=np.int16, type=np.matrix)
|
Chris@87
|
4632 >>> y
|
Chris@87
|
4633 matrix([[513]], dtype=int16)
|
Chris@87
|
4634 >>> print type(y)
|
Chris@87
|
4635 <class 'numpy.matrixlib.defmatrix.matrix'>
|
Chris@87
|
4636
|
Chris@87
|
4637 Creating a view on a structured array so it can be used in calculations
|
Chris@87
|
4638
|
Chris@87
|
4639 >>> x = np.array([(1, 2),(3,4)], dtype=[('a', np.int8), ('b', np.int8)])
|
Chris@87
|
4640 >>> xv = x.view(dtype=np.int8).reshape(-1,2)
|
Chris@87
|
4641 >>> xv
|
Chris@87
|
4642 array([[1, 2],
|
Chris@87
|
4643 [3, 4]], dtype=int8)
|
Chris@87
|
4644 >>> xv.mean(0)
|
Chris@87
|
4645 array([ 2., 3.])
|
Chris@87
|
4646
|
Chris@87
|
4647 Making changes to the view changes the underlying array
|
Chris@87
|
4648
|
Chris@87
|
4649 >>> xv[0,1] = 20
|
Chris@87
|
4650 >>> print x
|
Chris@87
|
4651 [(1, 20) (3, 4)]
|
Chris@87
|
4652
|
Chris@87
|
4653 Using a view to convert an array to a record array:
|
Chris@87
|
4654
|
Chris@87
|
4655 >>> z = x.view(np.recarray)
|
Chris@87
|
4656 >>> z.a
|
Chris@87
|
4657 array([1], dtype=int8)
|
Chris@87
|
4658
|
Chris@87
|
4659 Views share data:
|
Chris@87
|
4660
|
Chris@87
|
4661 >>> x[0] = (9, 10)
|
Chris@87
|
4662 >>> z[0]
|
Chris@87
|
4663 (9, 10)
|
Chris@87
|
4664
|
Chris@87
|
4665 Views that change the dtype size (bytes per entry) should normally be
|
Chris@87
|
4666 avoided on arrays defined by slices, transposes, fortran-ordering, etc.:
|
Chris@87
|
4667
|
Chris@87
|
4668 >>> x = np.array([[1,2,3],[4,5,6]], dtype=np.int16)
|
Chris@87
|
4669 >>> y = x[:, 0:2]
|
Chris@87
|
4670 >>> y
|
Chris@87
|
4671 array([[1, 2],
|
Chris@87
|
4672 [4, 5]], dtype=int16)
|
Chris@87
|
4673 >>> y.view(dtype=[('width', np.int16), ('length', np.int16)])
|
Chris@87
|
4674 Traceback (most recent call last):
|
Chris@87
|
4675 File "<stdin>", line 1, in <module>
|
Chris@87
|
4676 ValueError: new type not compatible with array.
|
Chris@87
|
4677 >>> z = y.copy()
|
Chris@87
|
4678 >>> z.view(dtype=[('width', np.int16), ('length', np.int16)])
|
Chris@87
|
4679 array([[(1, 2)],
|
Chris@87
|
4680 [(4, 5)]], dtype=[('width', '<i2'), ('length', '<i2')])
|
Chris@87
|
4681 """))
|
Chris@87
|
4682
|
Chris@87
|
4683
|
Chris@87
|
4684 ##############################################################################
|
Chris@87
|
4685 #
|
Chris@87
|
4686 # umath functions
|
Chris@87
|
4687 #
|
Chris@87
|
4688 ##############################################################################
|
Chris@87
|
4689
|
Chris@87
|
4690 add_newdoc('numpy.core.umath', 'frompyfunc',
|
Chris@87
|
4691 """
|
Chris@87
|
4692 frompyfunc(func, nin, nout)
|
Chris@87
|
4693
|
Chris@87
|
4694 Takes an arbitrary Python function and returns a Numpy ufunc.
|
Chris@87
|
4695
|
Chris@87
|
4696 Can be used, for example, to add broadcasting to a built-in Python
|
Chris@87
|
4697 function (see Examples section).
|
Chris@87
|
4698
|
Chris@87
|
4699 Parameters
|
Chris@87
|
4700 ----------
|
Chris@87
|
4701 func : Python function object
|
Chris@87
|
4702 An arbitrary Python function.
|
Chris@87
|
4703 nin : int
|
Chris@87
|
4704 The number of input arguments.
|
Chris@87
|
4705 nout : int
|
Chris@87
|
4706 The number of objects returned by `func`.
|
Chris@87
|
4707
|
Chris@87
|
4708 Returns
|
Chris@87
|
4709 -------
|
Chris@87
|
4710 out : ufunc
|
Chris@87
|
4711 Returns a Numpy universal function (``ufunc``) object.
|
Chris@87
|
4712
|
Chris@87
|
4713 Notes
|
Chris@87
|
4714 -----
|
Chris@87
|
4715 The returned ufunc always returns PyObject arrays.
|
Chris@87
|
4716
|
Chris@87
|
4717 Examples
|
Chris@87
|
4718 --------
|
Chris@87
|
4719 Use frompyfunc to add broadcasting to the Python function ``oct``:
|
Chris@87
|
4720
|
Chris@87
|
4721 >>> oct_array = np.frompyfunc(oct, 1, 1)
|
Chris@87
|
4722 >>> oct_array(np.array((10, 30, 100)))
|
Chris@87
|
4723 array([012, 036, 0144], dtype=object)
|
Chris@87
|
4724 >>> np.array((oct(10), oct(30), oct(100))) # for comparison
|
Chris@87
|
4725 array(['012', '036', '0144'],
|
Chris@87
|
4726 dtype='|S4')
|
Chris@87
|
4727
|
Chris@87
|
4728 """)
|
Chris@87
|
4729
|
Chris@87
|
4730 add_newdoc('numpy.core.umath', 'geterrobj',
|
Chris@87
|
4731 """
|
Chris@87
|
4732 geterrobj()
|
Chris@87
|
4733
|
Chris@87
|
4734 Return the current object that defines floating-point error handling.
|
Chris@87
|
4735
|
Chris@87
|
4736 The error object contains all information that defines the error handling
|
Chris@87
|
4737 behavior in Numpy. `geterrobj` is used internally by the other
|
Chris@87
|
4738 functions that get and set error handling behavior (`geterr`, `seterr`,
|
Chris@87
|
4739 `geterrcall`, `seterrcall`).
|
Chris@87
|
4740
|
Chris@87
|
4741 Returns
|
Chris@87
|
4742 -------
|
Chris@87
|
4743 errobj : list
|
Chris@87
|
4744 The error object, a list containing three elements:
|
Chris@87
|
4745 [internal numpy buffer size, error mask, error callback function].
|
Chris@87
|
4746
|
Chris@87
|
4747 The error mask is a single integer that holds the treatment information
|
Chris@87
|
4748 on all four floating point errors. The information for each error type
|
Chris@87
|
4749 is contained in three bits of the integer. If we print it in base 8, we
|
Chris@87
|
4750 can see what treatment is set for "invalid", "under", "over", and
|
Chris@87
|
4751 "divide" (in that order). The printed string can be interpreted with
|
Chris@87
|
4752
|
Chris@87
|
4753 * 0 : 'ignore'
|
Chris@87
|
4754 * 1 : 'warn'
|
Chris@87
|
4755 * 2 : 'raise'
|
Chris@87
|
4756 * 3 : 'call'
|
Chris@87
|
4757 * 4 : 'print'
|
Chris@87
|
4758 * 5 : 'log'
|
Chris@87
|
4759
|
Chris@87
|
4760 See Also
|
Chris@87
|
4761 --------
|
Chris@87
|
4762 seterrobj, seterr, geterr, seterrcall, geterrcall
|
Chris@87
|
4763 getbufsize, setbufsize
|
Chris@87
|
4764
|
Chris@87
|
4765 Notes
|
Chris@87
|
4766 -----
|
Chris@87
|
4767 For complete documentation of the types of floating-point exceptions and
|
Chris@87
|
4768 treatment options, see `seterr`.
|
Chris@87
|
4769
|
Chris@87
|
4770 Examples
|
Chris@87
|
4771 --------
|
Chris@87
|
4772 >>> np.geterrobj() # first get the defaults
|
Chris@87
|
4773 [10000, 0, None]
|
Chris@87
|
4774
|
Chris@87
|
4775 >>> def err_handler(type, flag):
|
Chris@87
|
4776 ... print "Floating point error (%s), with flag %s" % (type, flag)
|
Chris@87
|
4777 ...
|
Chris@87
|
4778 >>> old_bufsize = np.setbufsize(20000)
|
Chris@87
|
4779 >>> old_err = np.seterr(divide='raise')
|
Chris@87
|
4780 >>> old_handler = np.seterrcall(err_handler)
|
Chris@87
|
4781 >>> np.geterrobj()
|
Chris@87
|
4782 [20000, 2, <function err_handler at 0x91dcaac>]
|
Chris@87
|
4783
|
Chris@87
|
4784 >>> old_err = np.seterr(all='ignore')
|
Chris@87
|
4785 >>> np.base_repr(np.geterrobj()[1], 8)
|
Chris@87
|
4786 '0'
|
Chris@87
|
4787 >>> old_err = np.seterr(divide='warn', over='log', under='call',
|
Chris@87
|
4788 invalid='print')
|
Chris@87
|
4789 >>> np.base_repr(np.geterrobj()[1], 8)
|
Chris@87
|
4790 '4351'
|
Chris@87
|
4791
|
Chris@87
|
4792 """)
|
Chris@87
|
4793
|
Chris@87
|
4794 add_newdoc('numpy.core.umath', 'seterrobj',
|
Chris@87
|
4795 """
|
Chris@87
|
4796 seterrobj(errobj)
|
Chris@87
|
4797
|
Chris@87
|
4798 Set the object that defines floating-point error handling.
|
Chris@87
|
4799
|
Chris@87
|
4800 The error object contains all information that defines the error handling
|
Chris@87
|
4801 behavior in Numpy. `seterrobj` is used internally by the other
|
Chris@87
|
4802 functions that set error handling behavior (`seterr`, `seterrcall`).
|
Chris@87
|
4803
|
Chris@87
|
4804 Parameters
|
Chris@87
|
4805 ----------
|
Chris@87
|
4806 errobj : list
|
Chris@87
|
4807 The error object, a list containing three elements:
|
Chris@87
|
4808 [internal numpy buffer size, error mask, error callback function].
|
Chris@87
|
4809
|
Chris@87
|
4810 The error mask is a single integer that holds the treatment information
|
Chris@87
|
4811 on all four floating point errors. The information for each error type
|
Chris@87
|
4812 is contained in three bits of the integer. If we print it in base 8, we
|
Chris@87
|
4813 can see what treatment is set for "invalid", "under", "over", and
|
Chris@87
|
4814 "divide" (in that order). The printed string can be interpreted with
|
Chris@87
|
4815
|
Chris@87
|
4816 * 0 : 'ignore'
|
Chris@87
|
4817 * 1 : 'warn'
|
Chris@87
|
4818 * 2 : 'raise'
|
Chris@87
|
4819 * 3 : 'call'
|
Chris@87
|
4820 * 4 : 'print'
|
Chris@87
|
4821 * 5 : 'log'
|
Chris@87
|
4822
|
Chris@87
|
4823 See Also
|
Chris@87
|
4824 --------
|
Chris@87
|
4825 geterrobj, seterr, geterr, seterrcall, geterrcall
|
Chris@87
|
4826 getbufsize, setbufsize
|
Chris@87
|
4827
|
Chris@87
|
4828 Notes
|
Chris@87
|
4829 -----
|
Chris@87
|
4830 For complete documentation of the types of floating-point exceptions and
|
Chris@87
|
4831 treatment options, see `seterr`.
|
Chris@87
|
4832
|
Chris@87
|
4833 Examples
|
Chris@87
|
4834 --------
|
Chris@87
|
4835 >>> old_errobj = np.geterrobj() # first get the defaults
|
Chris@87
|
4836 >>> old_errobj
|
Chris@87
|
4837 [10000, 0, None]
|
Chris@87
|
4838
|
Chris@87
|
4839 >>> def err_handler(type, flag):
|
Chris@87
|
4840 ... print "Floating point error (%s), with flag %s" % (type, flag)
|
Chris@87
|
4841 ...
|
Chris@87
|
4842 >>> new_errobj = [20000, 12, err_handler]
|
Chris@87
|
4843 >>> np.seterrobj(new_errobj)
|
Chris@87
|
4844 >>> np.base_repr(12, 8) # int for divide=4 ('print') and over=1 ('warn')
|
Chris@87
|
4845 '14'
|
Chris@87
|
4846 >>> np.geterr()
|
Chris@87
|
4847 {'over': 'warn', 'divide': 'print', 'invalid': 'ignore', 'under': 'ignore'}
|
Chris@87
|
4848 >>> np.geterrcall() is err_handler
|
Chris@87
|
4849 True
|
Chris@87
|
4850
|
Chris@87
|
4851 """)
|
Chris@87
|
4852
|
Chris@87
|
4853
|
Chris@87
|
4854 ##############################################################################
|
Chris@87
|
4855 #
|
Chris@87
|
4856 # lib._compiled_base functions
|
Chris@87
|
4857 #
|
Chris@87
|
4858 ##############################################################################
|
Chris@87
|
4859
|
Chris@87
|
4860 add_newdoc('numpy.lib._compiled_base', 'digitize',
|
Chris@87
|
4861 """
|
Chris@87
|
4862 digitize(x, bins, right=False)
|
Chris@87
|
4863
|
Chris@87
|
4864 Return the indices of the bins to which each value in input array belongs.
|
Chris@87
|
4865
|
Chris@87
|
4866 Each index ``i`` returned is such that ``bins[i-1] <= x < bins[i]`` if
|
Chris@87
|
4867 `bins` is monotonically increasing, or ``bins[i-1] > x >= bins[i]`` if
|
Chris@87
|
4868 `bins` is monotonically decreasing. If values in `x` are beyond the
|
Chris@87
|
4869 bounds of `bins`, 0 or ``len(bins)`` is returned as appropriate. If right
|
Chris@87
|
4870 is True, then the right bin is closed so that the index ``i`` is such
|
Chris@87
|
4871 that ``bins[i-1] < x <= bins[i]`` or bins[i-1] >= x > bins[i]`` if `bins`
|
Chris@87
|
4872 is monotonically increasing or decreasing, respectively.
|
Chris@87
|
4873
|
Chris@87
|
4874 Parameters
|
Chris@87
|
4875 ----------
|
Chris@87
|
4876 x : array_like
|
Chris@87
|
4877 Input array to be binned. It has to be 1-dimensional.
|
Chris@87
|
4878 bins : array_like
|
Chris@87
|
4879 Array of bins. It has to be 1-dimensional and monotonic.
|
Chris@87
|
4880 right : bool, optional
|
Chris@87
|
4881 Indicating whether the intervals include the right or the left bin
|
Chris@87
|
4882 edge. Default behavior is (right==False) indicating that the interval
|
Chris@87
|
4883 does not include the right edge. The left bin and is open in this
|
Chris@87
|
4884 case. Ie., bins[i-1] <= x < bins[i] is the default behavior for
|
Chris@87
|
4885 monotonically increasing bins.
|
Chris@87
|
4886
|
Chris@87
|
4887 Returns
|
Chris@87
|
4888 -------
|
Chris@87
|
4889 out : ndarray of ints
|
Chris@87
|
4890 Output array of indices, of same shape as `x`.
|
Chris@87
|
4891
|
Chris@87
|
4892 Raises
|
Chris@87
|
4893 ------
|
Chris@87
|
4894 ValueError
|
Chris@87
|
4895 If the input is not 1-dimensional, or if `bins` is not monotonic.
|
Chris@87
|
4896 TypeError
|
Chris@87
|
4897 If the type of the input is complex.
|
Chris@87
|
4898
|
Chris@87
|
4899 See Also
|
Chris@87
|
4900 --------
|
Chris@87
|
4901 bincount, histogram, unique
|
Chris@87
|
4902
|
Chris@87
|
4903 Notes
|
Chris@87
|
4904 -----
|
Chris@87
|
4905 If values in `x` are such that they fall outside the bin range,
|
Chris@87
|
4906 attempting to index `bins` with the indices that `digitize` returns
|
Chris@87
|
4907 will result in an IndexError.
|
Chris@87
|
4908
|
Chris@87
|
4909 Examples
|
Chris@87
|
4910 --------
|
Chris@87
|
4911 >>> x = np.array([0.2, 6.4, 3.0, 1.6])
|
Chris@87
|
4912 >>> bins = np.array([0.0, 1.0, 2.5, 4.0, 10.0])
|
Chris@87
|
4913 >>> inds = np.digitize(x, bins)
|
Chris@87
|
4914 >>> inds
|
Chris@87
|
4915 array([1, 4, 3, 2])
|
Chris@87
|
4916 >>> for n in range(x.size):
|
Chris@87
|
4917 ... print bins[inds[n]-1], "<=", x[n], "<", bins[inds[n]]
|
Chris@87
|
4918 ...
|
Chris@87
|
4919 0.0 <= 0.2 < 1.0
|
Chris@87
|
4920 4.0 <= 6.4 < 10.0
|
Chris@87
|
4921 2.5 <= 3.0 < 4.0
|
Chris@87
|
4922 1.0 <= 1.6 < 2.5
|
Chris@87
|
4923
|
Chris@87
|
4924 >>> x = np.array([1.2, 10.0, 12.4, 15.5, 20.])
|
Chris@87
|
4925 >>> bins = np.array([0,5,10,15,20])
|
Chris@87
|
4926 >>> np.digitize(x,bins,right=True)
|
Chris@87
|
4927 array([1, 2, 3, 4, 4])
|
Chris@87
|
4928 >>> np.digitize(x,bins,right=False)
|
Chris@87
|
4929 array([1, 3, 3, 4, 5])
|
Chris@87
|
4930 """)
|
Chris@87
|
4931
|
Chris@87
|
4932 add_newdoc('numpy.lib._compiled_base', 'bincount',
|
Chris@87
|
4933 """
|
Chris@87
|
4934 bincount(x, weights=None, minlength=None)
|
Chris@87
|
4935
|
Chris@87
|
4936 Count number of occurrences of each value in array of non-negative ints.
|
Chris@87
|
4937
|
Chris@87
|
4938 The number of bins (of size 1) is one larger than the largest value in
|
Chris@87
|
4939 `x`. If `minlength` is specified, there will be at least this number
|
Chris@87
|
4940 of bins in the output array (though it will be longer if necessary,
|
Chris@87
|
4941 depending on the contents of `x`).
|
Chris@87
|
4942 Each bin gives the number of occurrences of its index value in `x`.
|
Chris@87
|
4943 If `weights` is specified the input array is weighted by it, i.e. if a
|
Chris@87
|
4944 value ``n`` is found at position ``i``, ``out[n] += weight[i]`` instead
|
Chris@87
|
4945 of ``out[n] += 1``.
|
Chris@87
|
4946
|
Chris@87
|
4947 Parameters
|
Chris@87
|
4948 ----------
|
Chris@87
|
4949 x : array_like, 1 dimension, nonnegative ints
|
Chris@87
|
4950 Input array.
|
Chris@87
|
4951 weights : array_like, optional
|
Chris@87
|
4952 Weights, array of the same shape as `x`.
|
Chris@87
|
4953 minlength : int, optional
|
Chris@87
|
4954 .. versionadded:: 1.6.0
|
Chris@87
|
4955
|
Chris@87
|
4956 A minimum number of bins for the output array.
|
Chris@87
|
4957
|
Chris@87
|
4958 Returns
|
Chris@87
|
4959 -------
|
Chris@87
|
4960 out : ndarray of ints
|
Chris@87
|
4961 The result of binning the input array.
|
Chris@87
|
4962 The length of `out` is equal to ``np.amax(x)+1``.
|
Chris@87
|
4963
|
Chris@87
|
4964 Raises
|
Chris@87
|
4965 ------
|
Chris@87
|
4966 ValueError
|
Chris@87
|
4967 If the input is not 1-dimensional, or contains elements with negative
|
Chris@87
|
4968 values, or if `minlength` is non-positive.
|
Chris@87
|
4969 TypeError
|
Chris@87
|
4970 If the type of the input is float or complex.
|
Chris@87
|
4971
|
Chris@87
|
4972 See Also
|
Chris@87
|
4973 --------
|
Chris@87
|
4974 histogram, digitize, unique
|
Chris@87
|
4975
|
Chris@87
|
4976 Examples
|
Chris@87
|
4977 --------
|
Chris@87
|
4978 >>> np.bincount(np.arange(5))
|
Chris@87
|
4979 array([1, 1, 1, 1, 1])
|
Chris@87
|
4980 >>> np.bincount(np.array([0, 1, 1, 3, 2, 1, 7]))
|
Chris@87
|
4981 array([1, 3, 1, 1, 0, 0, 0, 1])
|
Chris@87
|
4982
|
Chris@87
|
4983 >>> x = np.array([0, 1, 1, 3, 2, 1, 7, 23])
|
Chris@87
|
4984 >>> np.bincount(x).size == np.amax(x)+1
|
Chris@87
|
4985 True
|
Chris@87
|
4986
|
Chris@87
|
4987 The input array needs to be of integer dtype, otherwise a
|
Chris@87
|
4988 TypeError is raised:
|
Chris@87
|
4989
|
Chris@87
|
4990 >>> np.bincount(np.arange(5, dtype=np.float))
|
Chris@87
|
4991 Traceback (most recent call last):
|
Chris@87
|
4992 File "<stdin>", line 1, in <module>
|
Chris@87
|
4993 TypeError: array cannot be safely cast to required type
|
Chris@87
|
4994
|
Chris@87
|
4995 A possible use of ``bincount`` is to perform sums over
|
Chris@87
|
4996 variable-size chunks of an array, using the ``weights`` keyword.
|
Chris@87
|
4997
|
Chris@87
|
4998 >>> w = np.array([0.3, 0.5, 0.2, 0.7, 1., -0.6]) # weights
|
Chris@87
|
4999 >>> x = np.array([0, 1, 1, 2, 2, 2])
|
Chris@87
|
5000 >>> np.bincount(x, weights=w)
|
Chris@87
|
5001 array([ 0.3, 0.7, 1.1])
|
Chris@87
|
5002
|
Chris@87
|
5003 """)
|
Chris@87
|
5004
|
Chris@87
|
5005 add_newdoc('numpy.lib._compiled_base', 'ravel_multi_index',
|
Chris@87
|
5006 """
|
Chris@87
|
5007 ravel_multi_index(multi_index, dims, mode='raise', order='C')
|
Chris@87
|
5008
|
Chris@87
|
5009 Converts a tuple of index arrays into an array of flat
|
Chris@87
|
5010 indices, applying boundary modes to the multi-index.
|
Chris@87
|
5011
|
Chris@87
|
5012 Parameters
|
Chris@87
|
5013 ----------
|
Chris@87
|
5014 multi_index : tuple of array_like
|
Chris@87
|
5015 A tuple of integer arrays, one array for each dimension.
|
Chris@87
|
5016 dims : tuple of ints
|
Chris@87
|
5017 The shape of array into which the indices from ``multi_index`` apply.
|
Chris@87
|
5018 mode : {'raise', 'wrap', 'clip'}, optional
|
Chris@87
|
5019 Specifies how out-of-bounds indices are handled. Can specify
|
Chris@87
|
5020 either one mode or a tuple of modes, one mode per index.
|
Chris@87
|
5021
|
Chris@87
|
5022 * 'raise' -- raise an error (default)
|
Chris@87
|
5023 * 'wrap' -- wrap around
|
Chris@87
|
5024 * 'clip' -- clip to the range
|
Chris@87
|
5025
|
Chris@87
|
5026 In 'clip' mode, a negative index which would normally
|
Chris@87
|
5027 wrap will clip to 0 instead.
|
Chris@87
|
5028 order : {'C', 'F'}, optional
|
Chris@87
|
5029 Determines whether the multi-index should be viewed as indexing in
|
Chris@87
|
5030 C (row-major) order or FORTRAN (column-major) order.
|
Chris@87
|
5031
|
Chris@87
|
5032 Returns
|
Chris@87
|
5033 -------
|
Chris@87
|
5034 raveled_indices : ndarray
|
Chris@87
|
5035 An array of indices into the flattened version of an array
|
Chris@87
|
5036 of dimensions ``dims``.
|
Chris@87
|
5037
|
Chris@87
|
5038 See Also
|
Chris@87
|
5039 --------
|
Chris@87
|
5040 unravel_index
|
Chris@87
|
5041
|
Chris@87
|
5042 Notes
|
Chris@87
|
5043 -----
|
Chris@87
|
5044 .. versionadded:: 1.6.0
|
Chris@87
|
5045
|
Chris@87
|
5046 Examples
|
Chris@87
|
5047 --------
|
Chris@87
|
5048 >>> arr = np.array([[3,6,6],[4,5,1]])
|
Chris@87
|
5049 >>> np.ravel_multi_index(arr, (7,6))
|
Chris@87
|
5050 array([22, 41, 37])
|
Chris@87
|
5051 >>> np.ravel_multi_index(arr, (7,6), order='F')
|
Chris@87
|
5052 array([31, 41, 13])
|
Chris@87
|
5053 >>> np.ravel_multi_index(arr, (4,6), mode='clip')
|
Chris@87
|
5054 array([22, 23, 19])
|
Chris@87
|
5055 >>> np.ravel_multi_index(arr, (4,4), mode=('clip','wrap'))
|
Chris@87
|
5056 array([12, 13, 13])
|
Chris@87
|
5057
|
Chris@87
|
5058 >>> np.ravel_multi_index((3,1,4,1), (6,7,8,9))
|
Chris@87
|
5059 1621
|
Chris@87
|
5060 """)
|
Chris@87
|
5061
|
Chris@87
|
5062 add_newdoc('numpy.lib._compiled_base', 'unravel_index',
|
Chris@87
|
5063 """
|
Chris@87
|
5064 unravel_index(indices, dims, order='C')
|
Chris@87
|
5065
|
Chris@87
|
5066 Converts a flat index or array of flat indices into a tuple
|
Chris@87
|
5067 of coordinate arrays.
|
Chris@87
|
5068
|
Chris@87
|
5069 Parameters
|
Chris@87
|
5070 ----------
|
Chris@87
|
5071 indices : array_like
|
Chris@87
|
5072 An integer array whose elements are indices into the flattened
|
Chris@87
|
5073 version of an array of dimensions ``dims``. Before version 1.6.0,
|
Chris@87
|
5074 this function accepted just one index value.
|
Chris@87
|
5075 dims : tuple of ints
|
Chris@87
|
5076 The shape of the array to use for unraveling ``indices``.
|
Chris@87
|
5077 order : {'C', 'F'}, optional
|
Chris@87
|
5078 .. versionadded:: 1.6.0
|
Chris@87
|
5079
|
Chris@87
|
5080 Determines whether the indices should be viewed as indexing in
|
Chris@87
|
5081 C (row-major) order or FORTRAN (column-major) order.
|
Chris@87
|
5082
|
Chris@87
|
5083 Returns
|
Chris@87
|
5084 -------
|
Chris@87
|
5085 unraveled_coords : tuple of ndarray
|
Chris@87
|
5086 Each array in the tuple has the same shape as the ``indices``
|
Chris@87
|
5087 array.
|
Chris@87
|
5088
|
Chris@87
|
5089 See Also
|
Chris@87
|
5090 --------
|
Chris@87
|
5091 ravel_multi_index
|
Chris@87
|
5092
|
Chris@87
|
5093 Examples
|
Chris@87
|
5094 --------
|
Chris@87
|
5095 >>> np.unravel_index([22, 41, 37], (7,6))
|
Chris@87
|
5096 (array([3, 6, 6]), array([4, 5, 1]))
|
Chris@87
|
5097 >>> np.unravel_index([31, 41, 13], (7,6), order='F')
|
Chris@87
|
5098 (array([3, 6, 6]), array([4, 5, 1]))
|
Chris@87
|
5099
|
Chris@87
|
5100 >>> np.unravel_index(1621, (6,7,8,9))
|
Chris@87
|
5101 (3, 1, 4, 1)
|
Chris@87
|
5102
|
Chris@87
|
5103 """)
|
Chris@87
|
5104
|
Chris@87
|
5105 add_newdoc('numpy.lib._compiled_base', 'add_docstring',
|
Chris@87
|
5106 """
|
Chris@87
|
5107 add_docstring(obj, docstring)
|
Chris@87
|
5108
|
Chris@87
|
5109 Add a docstring to a built-in obj if possible.
|
Chris@87
|
5110 If the obj already has a docstring raise a RuntimeError
|
Chris@87
|
5111 If this routine does not know how to add a docstring to the object
|
Chris@87
|
5112 raise a TypeError
|
Chris@87
|
5113 """)
|
Chris@87
|
5114
|
Chris@87
|
5115 add_newdoc('numpy.lib._compiled_base', 'add_newdoc_ufunc',
|
Chris@87
|
5116 """
|
Chris@87
|
5117 add_ufunc_docstring(ufunc, new_docstring)
|
Chris@87
|
5118
|
Chris@87
|
5119 Replace the docstring for a ufunc with new_docstring.
|
Chris@87
|
5120 This method will only work if the current docstring for
|
Chris@87
|
5121 the ufunc is NULL. (At the C level, i.e. when ufunc->doc is NULL.)
|
Chris@87
|
5122
|
Chris@87
|
5123 Parameters
|
Chris@87
|
5124 ----------
|
Chris@87
|
5125 ufunc : numpy.ufunc
|
Chris@87
|
5126 A ufunc whose current doc is NULL.
|
Chris@87
|
5127 new_docstring : string
|
Chris@87
|
5128 The new docstring for the ufunc.
|
Chris@87
|
5129
|
Chris@87
|
5130 Notes
|
Chris@87
|
5131 -----
|
Chris@87
|
5132 This method allocates memory for new_docstring on
|
Chris@87
|
5133 the heap. Technically this creates a mempory leak, since this
|
Chris@87
|
5134 memory will not be reclaimed until the end of the program
|
Chris@87
|
5135 even if the ufunc itself is removed. However this will only
|
Chris@87
|
5136 be a problem if the user is repeatedly creating ufuncs with
|
Chris@87
|
5137 no documentation, adding documentation via add_newdoc_ufunc,
|
Chris@87
|
5138 and then throwing away the ufunc.
|
Chris@87
|
5139 """)
|
Chris@87
|
5140
|
Chris@87
|
5141 add_newdoc('numpy.lib._compiled_base', 'packbits',
|
Chris@87
|
5142 """
|
Chris@87
|
5143 packbits(myarray, axis=None)
|
Chris@87
|
5144
|
Chris@87
|
5145 Packs the elements of a binary-valued array into bits in a uint8 array.
|
Chris@87
|
5146
|
Chris@87
|
5147 The result is padded to full bytes by inserting zero bits at the end.
|
Chris@87
|
5148
|
Chris@87
|
5149 Parameters
|
Chris@87
|
5150 ----------
|
Chris@87
|
5151 myarray : array_like
|
Chris@87
|
5152 An integer type array whose elements should be packed to bits.
|
Chris@87
|
5153 axis : int, optional
|
Chris@87
|
5154 The dimension over which bit-packing is done.
|
Chris@87
|
5155 ``None`` implies packing the flattened array.
|
Chris@87
|
5156
|
Chris@87
|
5157 Returns
|
Chris@87
|
5158 -------
|
Chris@87
|
5159 packed : ndarray
|
Chris@87
|
5160 Array of type uint8 whose elements represent bits corresponding to the
|
Chris@87
|
5161 logical (0 or nonzero) value of the input elements. The shape of
|
Chris@87
|
5162 `packed` has the same number of dimensions as the input (unless `axis`
|
Chris@87
|
5163 is None, in which case the output is 1-D).
|
Chris@87
|
5164
|
Chris@87
|
5165 See Also
|
Chris@87
|
5166 --------
|
Chris@87
|
5167 unpackbits: Unpacks elements of a uint8 array into a binary-valued output
|
Chris@87
|
5168 array.
|
Chris@87
|
5169
|
Chris@87
|
5170 Examples
|
Chris@87
|
5171 --------
|
Chris@87
|
5172 >>> a = np.array([[[1,0,1],
|
Chris@87
|
5173 ... [0,1,0]],
|
Chris@87
|
5174 ... [[1,1,0],
|
Chris@87
|
5175 ... [0,0,1]]])
|
Chris@87
|
5176 >>> b = np.packbits(a, axis=-1)
|
Chris@87
|
5177 >>> b
|
Chris@87
|
5178 array([[[160],[64]],[[192],[32]]], dtype=uint8)
|
Chris@87
|
5179
|
Chris@87
|
5180 Note that in binary 160 = 1010 0000, 64 = 0100 0000, 192 = 1100 0000,
|
Chris@87
|
5181 and 32 = 0010 0000.
|
Chris@87
|
5182
|
Chris@87
|
5183 """)
|
Chris@87
|
5184
|
Chris@87
|
5185 add_newdoc('numpy.lib._compiled_base', 'unpackbits',
|
Chris@87
|
5186 """
|
Chris@87
|
5187 unpackbits(myarray, axis=None)
|
Chris@87
|
5188
|
Chris@87
|
5189 Unpacks elements of a uint8 array into a binary-valued output array.
|
Chris@87
|
5190
|
Chris@87
|
5191 Each element of `myarray` represents a bit-field that should be unpacked
|
Chris@87
|
5192 into a binary-valued output array. The shape of the output array is either
|
Chris@87
|
5193 1-D (if `axis` is None) or the same shape as the input array with unpacking
|
Chris@87
|
5194 done along the axis specified.
|
Chris@87
|
5195
|
Chris@87
|
5196 Parameters
|
Chris@87
|
5197 ----------
|
Chris@87
|
5198 myarray : ndarray, uint8 type
|
Chris@87
|
5199 Input array.
|
Chris@87
|
5200 axis : int, optional
|
Chris@87
|
5201 Unpacks along this axis.
|
Chris@87
|
5202
|
Chris@87
|
5203 Returns
|
Chris@87
|
5204 -------
|
Chris@87
|
5205 unpacked : ndarray, uint8 type
|
Chris@87
|
5206 The elements are binary-valued (0 or 1).
|
Chris@87
|
5207
|
Chris@87
|
5208 See Also
|
Chris@87
|
5209 --------
|
Chris@87
|
5210 packbits : Packs the elements of a binary-valued array into bits in a uint8
|
Chris@87
|
5211 array.
|
Chris@87
|
5212
|
Chris@87
|
5213 Examples
|
Chris@87
|
5214 --------
|
Chris@87
|
5215 >>> a = np.array([[2], [7], [23]], dtype=np.uint8)
|
Chris@87
|
5216 >>> a
|
Chris@87
|
5217 array([[ 2],
|
Chris@87
|
5218 [ 7],
|
Chris@87
|
5219 [23]], dtype=uint8)
|
Chris@87
|
5220 >>> b = np.unpackbits(a, axis=1)
|
Chris@87
|
5221 >>> b
|
Chris@87
|
5222 array([[0, 0, 0, 0, 0, 0, 1, 0],
|
Chris@87
|
5223 [0, 0, 0, 0, 0, 1, 1, 1],
|
Chris@87
|
5224 [0, 0, 0, 1, 0, 1, 1, 1]], dtype=uint8)
|
Chris@87
|
5225
|
Chris@87
|
5226 """)
|
Chris@87
|
5227
|
Chris@87
|
5228
|
Chris@87
|
5229 ##############################################################################
|
Chris@87
|
5230 #
|
Chris@87
|
5231 # Documentation for ufunc attributes and methods
|
Chris@87
|
5232 #
|
Chris@87
|
5233 ##############################################################################
|
Chris@87
|
5234
|
Chris@87
|
5235
|
Chris@87
|
5236 ##############################################################################
|
Chris@87
|
5237 #
|
Chris@87
|
5238 # ufunc object
|
Chris@87
|
5239 #
|
Chris@87
|
5240 ##############################################################################
|
Chris@87
|
5241
|
Chris@87
|
5242 add_newdoc('numpy.core', 'ufunc',
|
Chris@87
|
5243 """
|
Chris@87
|
5244 Functions that operate element by element on whole arrays.
|
Chris@87
|
5245
|
Chris@87
|
5246 To see the documentation for a specific ufunc, use np.info(). For
|
Chris@87
|
5247 example, np.info(np.sin). Because ufuncs are written in C
|
Chris@87
|
5248 (for speed) and linked into Python with NumPy's ufunc facility,
|
Chris@87
|
5249 Python's help() function finds this page whenever help() is called
|
Chris@87
|
5250 on a ufunc.
|
Chris@87
|
5251
|
Chris@87
|
5252 A detailed explanation of ufuncs can be found in the "ufuncs.rst"
|
Chris@87
|
5253 file in the NumPy reference guide.
|
Chris@87
|
5254
|
Chris@87
|
5255 Unary ufuncs:
|
Chris@87
|
5256 =============
|
Chris@87
|
5257
|
Chris@87
|
5258 op(X, out=None)
|
Chris@87
|
5259 Apply op to X elementwise
|
Chris@87
|
5260
|
Chris@87
|
5261 Parameters
|
Chris@87
|
5262 ----------
|
Chris@87
|
5263 X : array_like
|
Chris@87
|
5264 Input array.
|
Chris@87
|
5265 out : array_like
|
Chris@87
|
5266 An array to store the output. Must be the same shape as `X`.
|
Chris@87
|
5267
|
Chris@87
|
5268 Returns
|
Chris@87
|
5269 -------
|
Chris@87
|
5270 r : array_like
|
Chris@87
|
5271 `r` will have the same shape as `X`; if out is provided, `r`
|
Chris@87
|
5272 will be equal to out.
|
Chris@87
|
5273
|
Chris@87
|
5274 Binary ufuncs:
|
Chris@87
|
5275 ==============
|
Chris@87
|
5276
|
Chris@87
|
5277 op(X, Y, out=None)
|
Chris@87
|
5278 Apply `op` to `X` and `Y` elementwise. May "broadcast" to make
|
Chris@87
|
5279 the shapes of `X` and `Y` congruent.
|
Chris@87
|
5280
|
Chris@87
|
5281 The broadcasting rules are:
|
Chris@87
|
5282
|
Chris@87
|
5283 * Dimensions of length 1 may be prepended to either array.
|
Chris@87
|
5284 * Arrays may be repeated along dimensions of length 1.
|
Chris@87
|
5285
|
Chris@87
|
5286 Parameters
|
Chris@87
|
5287 ----------
|
Chris@87
|
5288 X : array_like
|
Chris@87
|
5289 First input array.
|
Chris@87
|
5290 Y : array_like
|
Chris@87
|
5291 Second input array.
|
Chris@87
|
5292 out : array_like
|
Chris@87
|
5293 An array to store the output. Must be the same shape as the
|
Chris@87
|
5294 output would have.
|
Chris@87
|
5295
|
Chris@87
|
5296 Returns
|
Chris@87
|
5297 -------
|
Chris@87
|
5298 r : array_like
|
Chris@87
|
5299 The return value; if out is provided, `r` will be equal to out.
|
Chris@87
|
5300
|
Chris@87
|
5301 """)
|
Chris@87
|
5302
|
Chris@87
|
5303
|
Chris@87
|
5304 ##############################################################################
|
Chris@87
|
5305 #
|
Chris@87
|
5306 # ufunc attributes
|
Chris@87
|
5307 #
|
Chris@87
|
5308 ##############################################################################
|
Chris@87
|
5309
|
Chris@87
|
5310 add_newdoc('numpy.core', 'ufunc', ('identity',
|
Chris@87
|
5311 """
|
Chris@87
|
5312 The identity value.
|
Chris@87
|
5313
|
Chris@87
|
5314 Data attribute containing the identity element for the ufunc, if it has one.
|
Chris@87
|
5315 If it does not, the attribute value is None.
|
Chris@87
|
5316
|
Chris@87
|
5317 Examples
|
Chris@87
|
5318 --------
|
Chris@87
|
5319 >>> np.add.identity
|
Chris@87
|
5320 0
|
Chris@87
|
5321 >>> np.multiply.identity
|
Chris@87
|
5322 1
|
Chris@87
|
5323 >>> np.power.identity
|
Chris@87
|
5324 1
|
Chris@87
|
5325 >>> print np.exp.identity
|
Chris@87
|
5326 None
|
Chris@87
|
5327 """))
|
Chris@87
|
5328
|
Chris@87
|
5329 add_newdoc('numpy.core', 'ufunc', ('nargs',
|
Chris@87
|
5330 """
|
Chris@87
|
5331 The number of arguments.
|
Chris@87
|
5332
|
Chris@87
|
5333 Data attribute containing the number of arguments the ufunc takes, including
|
Chris@87
|
5334 optional ones.
|
Chris@87
|
5335
|
Chris@87
|
5336 Notes
|
Chris@87
|
5337 -----
|
Chris@87
|
5338 Typically this value will be one more than what you might expect because all
|
Chris@87
|
5339 ufuncs take the optional "out" argument.
|
Chris@87
|
5340
|
Chris@87
|
5341 Examples
|
Chris@87
|
5342 --------
|
Chris@87
|
5343 >>> np.add.nargs
|
Chris@87
|
5344 3
|
Chris@87
|
5345 >>> np.multiply.nargs
|
Chris@87
|
5346 3
|
Chris@87
|
5347 >>> np.power.nargs
|
Chris@87
|
5348 3
|
Chris@87
|
5349 >>> np.exp.nargs
|
Chris@87
|
5350 2
|
Chris@87
|
5351 """))
|
Chris@87
|
5352
|
Chris@87
|
5353 add_newdoc('numpy.core', 'ufunc', ('nin',
|
Chris@87
|
5354 """
|
Chris@87
|
5355 The number of inputs.
|
Chris@87
|
5356
|
Chris@87
|
5357 Data attribute containing the number of arguments the ufunc treats as input.
|
Chris@87
|
5358
|
Chris@87
|
5359 Examples
|
Chris@87
|
5360 --------
|
Chris@87
|
5361 >>> np.add.nin
|
Chris@87
|
5362 2
|
Chris@87
|
5363 >>> np.multiply.nin
|
Chris@87
|
5364 2
|
Chris@87
|
5365 >>> np.power.nin
|
Chris@87
|
5366 2
|
Chris@87
|
5367 >>> np.exp.nin
|
Chris@87
|
5368 1
|
Chris@87
|
5369 """))
|
Chris@87
|
5370
|
Chris@87
|
5371 add_newdoc('numpy.core', 'ufunc', ('nout',
|
Chris@87
|
5372 """
|
Chris@87
|
5373 The number of outputs.
|
Chris@87
|
5374
|
Chris@87
|
5375 Data attribute containing the number of arguments the ufunc treats as output.
|
Chris@87
|
5376
|
Chris@87
|
5377 Notes
|
Chris@87
|
5378 -----
|
Chris@87
|
5379 Since all ufuncs can take output arguments, this will always be (at least) 1.
|
Chris@87
|
5380
|
Chris@87
|
5381 Examples
|
Chris@87
|
5382 --------
|
Chris@87
|
5383 >>> np.add.nout
|
Chris@87
|
5384 1
|
Chris@87
|
5385 >>> np.multiply.nout
|
Chris@87
|
5386 1
|
Chris@87
|
5387 >>> np.power.nout
|
Chris@87
|
5388 1
|
Chris@87
|
5389 >>> np.exp.nout
|
Chris@87
|
5390 1
|
Chris@87
|
5391
|
Chris@87
|
5392 """))
|
Chris@87
|
5393
|
Chris@87
|
5394 add_newdoc('numpy.core', 'ufunc', ('ntypes',
|
Chris@87
|
5395 """
|
Chris@87
|
5396 The number of types.
|
Chris@87
|
5397
|
Chris@87
|
5398 The number of numerical NumPy types - of which there are 18 total - on which
|
Chris@87
|
5399 the ufunc can operate.
|
Chris@87
|
5400
|
Chris@87
|
5401 See Also
|
Chris@87
|
5402 --------
|
Chris@87
|
5403 numpy.ufunc.types
|
Chris@87
|
5404
|
Chris@87
|
5405 Examples
|
Chris@87
|
5406 --------
|
Chris@87
|
5407 >>> np.add.ntypes
|
Chris@87
|
5408 18
|
Chris@87
|
5409 >>> np.multiply.ntypes
|
Chris@87
|
5410 18
|
Chris@87
|
5411 >>> np.power.ntypes
|
Chris@87
|
5412 17
|
Chris@87
|
5413 >>> np.exp.ntypes
|
Chris@87
|
5414 7
|
Chris@87
|
5415 >>> np.remainder.ntypes
|
Chris@87
|
5416 14
|
Chris@87
|
5417
|
Chris@87
|
5418 """))
|
Chris@87
|
5419
|
Chris@87
|
5420 add_newdoc('numpy.core', 'ufunc', ('types',
|
Chris@87
|
5421 """
|
Chris@87
|
5422 Returns a list with types grouped input->output.
|
Chris@87
|
5423
|
Chris@87
|
5424 Data attribute listing the data-type "Domain-Range" groupings the ufunc can
|
Chris@87
|
5425 deliver. The data-types are given using the character codes.
|
Chris@87
|
5426
|
Chris@87
|
5427 See Also
|
Chris@87
|
5428 --------
|
Chris@87
|
5429 numpy.ufunc.ntypes
|
Chris@87
|
5430
|
Chris@87
|
5431 Examples
|
Chris@87
|
5432 --------
|
Chris@87
|
5433 >>> np.add.types
|
Chris@87
|
5434 ['??->?', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
|
Chris@87
|
5435 'LL->L', 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D',
|
Chris@87
|
5436 'GG->G', 'OO->O']
|
Chris@87
|
5437
|
Chris@87
|
5438 >>> np.multiply.types
|
Chris@87
|
5439 ['??->?', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l',
|
Chris@87
|
5440 'LL->L', 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D',
|
Chris@87
|
5441 'GG->G', 'OO->O']
|
Chris@87
|
5442
|
Chris@87
|
5443 >>> np.power.types
|
Chris@87
|
5444 ['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
|
Chris@87
|
5445 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'FF->F', 'DD->D', 'GG->G',
|
Chris@87
|
5446 'OO->O']
|
Chris@87
|
5447
|
Chris@87
|
5448 >>> np.exp.types
|
Chris@87
|
5449 ['f->f', 'd->d', 'g->g', 'F->F', 'D->D', 'G->G', 'O->O']
|
Chris@87
|
5450
|
Chris@87
|
5451 >>> np.remainder.types
|
Chris@87
|
5452 ['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L',
|
Chris@87
|
5453 'qq->q', 'QQ->Q', 'ff->f', 'dd->d', 'gg->g', 'OO->O']
|
Chris@87
|
5454
|
Chris@87
|
5455 """))
|
Chris@87
|
5456
|
Chris@87
|
5457
|
Chris@87
|
5458 ##############################################################################
|
Chris@87
|
5459 #
|
Chris@87
|
5460 # ufunc methods
|
Chris@87
|
5461 #
|
Chris@87
|
5462 ##############################################################################
|
Chris@87
|
5463
|
Chris@87
|
5464 add_newdoc('numpy.core', 'ufunc', ('reduce',
|
Chris@87
|
5465 """
|
Chris@87
|
5466 reduce(a, axis=0, dtype=None, out=None, keepdims=False)
|
Chris@87
|
5467
|
Chris@87
|
5468 Reduces `a`'s dimension by one, by applying ufunc along one axis.
|
Chris@87
|
5469
|
Chris@87
|
5470 Let :math:`a.shape = (N_0, ..., N_i, ..., N_{M-1})`. Then
|
Chris@87
|
5471 :math:`ufunc.reduce(a, axis=i)[k_0, ..,k_{i-1}, k_{i+1}, .., k_{M-1}]` =
|
Chris@87
|
5472 the result of iterating `j` over :math:`range(N_i)`, cumulatively applying
|
Chris@87
|
5473 ufunc to each :math:`a[k_0, ..,k_{i-1}, j, k_{i+1}, .., k_{M-1}]`.
|
Chris@87
|
5474 For a one-dimensional array, reduce produces results equivalent to:
|
Chris@87
|
5475 ::
|
Chris@87
|
5476
|
Chris@87
|
5477 r = op.identity # op = ufunc
|
Chris@87
|
5478 for i in range(len(A)):
|
Chris@87
|
5479 r = op(r, A[i])
|
Chris@87
|
5480 return r
|
Chris@87
|
5481
|
Chris@87
|
5482 For example, add.reduce() is equivalent to sum().
|
Chris@87
|
5483
|
Chris@87
|
5484 Parameters
|
Chris@87
|
5485 ----------
|
Chris@87
|
5486 a : array_like
|
Chris@87
|
5487 The array to act on.
|
Chris@87
|
5488 axis : None or int or tuple of ints, optional
|
Chris@87
|
5489 Axis or axes along which a reduction is performed.
|
Chris@87
|
5490 The default (`axis` = 0) is perform a reduction over the first
|
Chris@87
|
5491 dimension of the input array. `axis` may be negative, in
|
Chris@87
|
5492 which case it counts from the last to the first axis.
|
Chris@87
|
5493
|
Chris@87
|
5494 .. versionadded:: 1.7.0
|
Chris@87
|
5495
|
Chris@87
|
5496 If this is `None`, a reduction is performed over all the axes.
|
Chris@87
|
5497 If this is a tuple of ints, a reduction is performed on multiple
|
Chris@87
|
5498 axes, instead of a single axis or all the axes as before.
|
Chris@87
|
5499
|
Chris@87
|
5500 For operations which are either not commutative or not associative,
|
Chris@87
|
5501 doing a reduction over multiple axes is not well-defined. The
|
Chris@87
|
5502 ufuncs do not currently raise an exception in this case, but will
|
Chris@87
|
5503 likely do so in the future.
|
Chris@87
|
5504 dtype : data-type code, optional
|
Chris@87
|
5505 The type used to represent the intermediate results. Defaults
|
Chris@87
|
5506 to the data-type of the output array if this is provided, or
|
Chris@87
|
5507 the data-type of the input array if no output array is provided.
|
Chris@87
|
5508 out : ndarray, optional
|
Chris@87
|
5509 A location into which the result is stored. If not provided, a
|
Chris@87
|
5510 freshly-allocated array is returned.
|
Chris@87
|
5511 keepdims : bool, optional
|
Chris@87
|
5512 If this is set to True, the axes which are reduced are left
|
Chris@87
|
5513 in the result as dimensions with size one. With this option,
|
Chris@87
|
5514 the result will broadcast correctly against the original `arr`.
|
Chris@87
|
5515
|
Chris@87
|
5516 .. versionadded:: 1.7.0
|
Chris@87
|
5517
|
Chris@87
|
5518 Returns
|
Chris@87
|
5519 -------
|
Chris@87
|
5520 r : ndarray
|
Chris@87
|
5521 The reduced array. If `out` was supplied, `r` is a reference to it.
|
Chris@87
|
5522
|
Chris@87
|
5523 Examples
|
Chris@87
|
5524 --------
|
Chris@87
|
5525 >>> np.multiply.reduce([2,3,5])
|
Chris@87
|
5526 30
|
Chris@87
|
5527
|
Chris@87
|
5528 A multi-dimensional array example:
|
Chris@87
|
5529
|
Chris@87
|
5530 >>> X = np.arange(8).reshape((2,2,2))
|
Chris@87
|
5531 >>> X
|
Chris@87
|
5532 array([[[0, 1],
|
Chris@87
|
5533 [2, 3]],
|
Chris@87
|
5534 [[4, 5],
|
Chris@87
|
5535 [6, 7]]])
|
Chris@87
|
5536 >>> np.add.reduce(X, 0)
|
Chris@87
|
5537 array([[ 4, 6],
|
Chris@87
|
5538 [ 8, 10]])
|
Chris@87
|
5539 >>> np.add.reduce(X) # confirm: default axis value is 0
|
Chris@87
|
5540 array([[ 4, 6],
|
Chris@87
|
5541 [ 8, 10]])
|
Chris@87
|
5542 >>> np.add.reduce(X, 1)
|
Chris@87
|
5543 array([[ 2, 4],
|
Chris@87
|
5544 [10, 12]])
|
Chris@87
|
5545 >>> np.add.reduce(X, 2)
|
Chris@87
|
5546 array([[ 1, 5],
|
Chris@87
|
5547 [ 9, 13]])
|
Chris@87
|
5548
|
Chris@87
|
5549 """))
|
Chris@87
|
5550
|
Chris@87
|
5551 add_newdoc('numpy.core', 'ufunc', ('accumulate',
|
Chris@87
|
5552 """
|
Chris@87
|
5553 accumulate(array, axis=0, dtype=None, out=None)
|
Chris@87
|
5554
|
Chris@87
|
5555 Accumulate the result of applying the operator to all elements.
|
Chris@87
|
5556
|
Chris@87
|
5557 For a one-dimensional array, accumulate produces results equivalent to::
|
Chris@87
|
5558
|
Chris@87
|
5559 r = np.empty(len(A))
|
Chris@87
|
5560 t = op.identity # op = the ufunc being applied to A's elements
|
Chris@87
|
5561 for i in range(len(A)):
|
Chris@87
|
5562 t = op(t, A[i])
|
Chris@87
|
5563 r[i] = t
|
Chris@87
|
5564 return r
|
Chris@87
|
5565
|
Chris@87
|
5566 For example, add.accumulate() is equivalent to np.cumsum().
|
Chris@87
|
5567
|
Chris@87
|
5568 For a multi-dimensional array, accumulate is applied along only one
|
Chris@87
|
5569 axis (axis zero by default; see Examples below) so repeated use is
|
Chris@87
|
5570 necessary if one wants to accumulate over multiple axes.
|
Chris@87
|
5571
|
Chris@87
|
5572 Parameters
|
Chris@87
|
5573 ----------
|
Chris@87
|
5574 array : array_like
|
Chris@87
|
5575 The array to act on.
|
Chris@87
|
5576 axis : int, optional
|
Chris@87
|
5577 The axis along which to apply the accumulation; default is zero.
|
Chris@87
|
5578 dtype : data-type code, optional
|
Chris@87
|
5579 The data-type used to represent the intermediate results. Defaults
|
Chris@87
|
5580 to the data-type of the output array if such is provided, or the
|
Chris@87
|
5581 the data-type of the input array if no output array is provided.
|
Chris@87
|
5582 out : ndarray, optional
|
Chris@87
|
5583 A location into which the result is stored. If not provided a
|
Chris@87
|
5584 freshly-allocated array is returned.
|
Chris@87
|
5585
|
Chris@87
|
5586 Returns
|
Chris@87
|
5587 -------
|
Chris@87
|
5588 r : ndarray
|
Chris@87
|
5589 The accumulated values. If `out` was supplied, `r` is a reference to
|
Chris@87
|
5590 `out`.
|
Chris@87
|
5591
|
Chris@87
|
5592 Examples
|
Chris@87
|
5593 --------
|
Chris@87
|
5594 1-D array examples:
|
Chris@87
|
5595
|
Chris@87
|
5596 >>> np.add.accumulate([2, 3, 5])
|
Chris@87
|
5597 array([ 2, 5, 10])
|
Chris@87
|
5598 >>> np.multiply.accumulate([2, 3, 5])
|
Chris@87
|
5599 array([ 2, 6, 30])
|
Chris@87
|
5600
|
Chris@87
|
5601 2-D array examples:
|
Chris@87
|
5602
|
Chris@87
|
5603 >>> I = np.eye(2)
|
Chris@87
|
5604 >>> I
|
Chris@87
|
5605 array([[ 1., 0.],
|
Chris@87
|
5606 [ 0., 1.]])
|
Chris@87
|
5607
|
Chris@87
|
5608 Accumulate along axis 0 (rows), down columns:
|
Chris@87
|
5609
|
Chris@87
|
5610 >>> np.add.accumulate(I, 0)
|
Chris@87
|
5611 array([[ 1., 0.],
|
Chris@87
|
5612 [ 1., 1.]])
|
Chris@87
|
5613 >>> np.add.accumulate(I) # no axis specified = axis zero
|
Chris@87
|
5614 array([[ 1., 0.],
|
Chris@87
|
5615 [ 1., 1.]])
|
Chris@87
|
5616
|
Chris@87
|
5617 Accumulate along axis 1 (columns), through rows:
|
Chris@87
|
5618
|
Chris@87
|
5619 >>> np.add.accumulate(I, 1)
|
Chris@87
|
5620 array([[ 1., 1.],
|
Chris@87
|
5621 [ 0., 1.]])
|
Chris@87
|
5622
|
Chris@87
|
5623 """))
|
Chris@87
|
5624
|
Chris@87
|
5625 add_newdoc('numpy.core', 'ufunc', ('reduceat',
|
Chris@87
|
5626 """
|
Chris@87
|
5627 reduceat(a, indices, axis=0, dtype=None, out=None)
|
Chris@87
|
5628
|
Chris@87
|
5629 Performs a (local) reduce with specified slices over a single axis.
|
Chris@87
|
5630
|
Chris@87
|
5631 For i in ``range(len(indices))``, `reduceat` computes
|
Chris@87
|
5632 ``ufunc.reduce(a[indices[i]:indices[i+1]])``, which becomes the i-th
|
Chris@87
|
5633 generalized "row" parallel to `axis` in the final result (i.e., in a
|
Chris@87
|
5634 2-D array, for example, if `axis = 0`, it becomes the i-th row, but if
|
Chris@87
|
5635 `axis = 1`, it becomes the i-th column). There are three exceptions to this:
|
Chris@87
|
5636
|
Chris@87
|
5637 * when ``i = len(indices) - 1`` (so for the last index),
|
Chris@87
|
5638 ``indices[i+1] = a.shape[axis]``.
|
Chris@87
|
5639 * if ``indices[i] >= indices[i + 1]``, the i-th generalized "row" is
|
Chris@87
|
5640 simply ``a[indices[i]]``.
|
Chris@87
|
5641 * if ``indices[i] >= len(a)`` or ``indices[i] < 0``, an error is raised.
|
Chris@87
|
5642
|
Chris@87
|
5643 The shape of the output depends on the size of `indices`, and may be
|
Chris@87
|
5644 larger than `a` (this happens if ``len(indices) > a.shape[axis]``).
|
Chris@87
|
5645
|
Chris@87
|
5646 Parameters
|
Chris@87
|
5647 ----------
|
Chris@87
|
5648 a : array_like
|
Chris@87
|
5649 The array to act on.
|
Chris@87
|
5650 indices : array_like
|
Chris@87
|
5651 Paired indices, comma separated (not colon), specifying slices to
|
Chris@87
|
5652 reduce.
|
Chris@87
|
5653 axis : int, optional
|
Chris@87
|
5654 The axis along which to apply the reduceat.
|
Chris@87
|
5655 dtype : data-type code, optional
|
Chris@87
|
5656 The type used to represent the intermediate results. Defaults
|
Chris@87
|
5657 to the data type of the output array if this is provided, or
|
Chris@87
|
5658 the data type of the input array if no output array is provided.
|
Chris@87
|
5659 out : ndarray, optional
|
Chris@87
|
5660 A location into which the result is stored. If not provided a
|
Chris@87
|
5661 freshly-allocated array is returned.
|
Chris@87
|
5662
|
Chris@87
|
5663 Returns
|
Chris@87
|
5664 -------
|
Chris@87
|
5665 r : ndarray
|
Chris@87
|
5666 The reduced values. If `out` was supplied, `r` is a reference to
|
Chris@87
|
5667 `out`.
|
Chris@87
|
5668
|
Chris@87
|
5669 Notes
|
Chris@87
|
5670 -----
|
Chris@87
|
5671 A descriptive example:
|
Chris@87
|
5672
|
Chris@87
|
5673 If `a` is 1-D, the function `ufunc.accumulate(a)` is the same as
|
Chris@87
|
5674 ``ufunc.reduceat(a, indices)[::2]`` where `indices` is
|
Chris@87
|
5675 ``range(len(array) - 1)`` with a zero placed
|
Chris@87
|
5676 in every other element:
|
Chris@87
|
5677 ``indices = zeros(2 * len(a) - 1)``, ``indices[1::2] = range(1, len(a))``.
|
Chris@87
|
5678
|
Chris@87
|
5679 Don't be fooled by this attribute's name: `reduceat(a)` is not
|
Chris@87
|
5680 necessarily smaller than `a`.
|
Chris@87
|
5681
|
Chris@87
|
5682 Examples
|
Chris@87
|
5683 --------
|
Chris@87
|
5684 To take the running sum of four successive values:
|
Chris@87
|
5685
|
Chris@87
|
5686 >>> np.add.reduceat(np.arange(8),[0,4, 1,5, 2,6, 3,7])[::2]
|
Chris@87
|
5687 array([ 6, 10, 14, 18])
|
Chris@87
|
5688
|
Chris@87
|
5689 A 2-D example:
|
Chris@87
|
5690
|
Chris@87
|
5691 >>> x = np.linspace(0, 15, 16).reshape(4,4)
|
Chris@87
|
5692 >>> x
|
Chris@87
|
5693 array([[ 0., 1., 2., 3.],
|
Chris@87
|
5694 [ 4., 5., 6., 7.],
|
Chris@87
|
5695 [ 8., 9., 10., 11.],
|
Chris@87
|
5696 [ 12., 13., 14., 15.]])
|
Chris@87
|
5697
|
Chris@87
|
5698 ::
|
Chris@87
|
5699
|
Chris@87
|
5700 # reduce such that the result has the following five rows:
|
Chris@87
|
5701 # [row1 + row2 + row3]
|
Chris@87
|
5702 # [row4]
|
Chris@87
|
5703 # [row2]
|
Chris@87
|
5704 # [row3]
|
Chris@87
|
5705 # [row1 + row2 + row3 + row4]
|
Chris@87
|
5706
|
Chris@87
|
5707 >>> np.add.reduceat(x, [0, 3, 1, 2, 0])
|
Chris@87
|
5708 array([[ 12., 15., 18., 21.],
|
Chris@87
|
5709 [ 12., 13., 14., 15.],
|
Chris@87
|
5710 [ 4., 5., 6., 7.],
|
Chris@87
|
5711 [ 8., 9., 10., 11.],
|
Chris@87
|
5712 [ 24., 28., 32., 36.]])
|
Chris@87
|
5713
|
Chris@87
|
5714 ::
|
Chris@87
|
5715
|
Chris@87
|
5716 # reduce such that result has the following two columns:
|
Chris@87
|
5717 # [col1 * col2 * col3, col4]
|
Chris@87
|
5718
|
Chris@87
|
5719 >>> np.multiply.reduceat(x, [0, 3], 1)
|
Chris@87
|
5720 array([[ 0., 3.],
|
Chris@87
|
5721 [ 120., 7.],
|
Chris@87
|
5722 [ 720., 11.],
|
Chris@87
|
5723 [ 2184., 15.]])
|
Chris@87
|
5724
|
Chris@87
|
5725 """))
|
Chris@87
|
5726
|
Chris@87
|
5727 add_newdoc('numpy.core', 'ufunc', ('outer',
|
Chris@87
|
5728 """
|
Chris@87
|
5729 outer(A, B)
|
Chris@87
|
5730
|
Chris@87
|
5731 Apply the ufunc `op` to all pairs (a, b) with a in `A` and b in `B`.
|
Chris@87
|
5732
|
Chris@87
|
5733 Let ``M = A.ndim``, ``N = B.ndim``. Then the result, `C`, of
|
Chris@87
|
5734 ``op.outer(A, B)`` is an array of dimension M + N such that:
|
Chris@87
|
5735
|
Chris@87
|
5736 .. math:: C[i_0, ..., i_{M-1}, j_0, ..., j_{N-1}] =
|
Chris@87
|
5737 op(A[i_0, ..., i_{M-1}], B[j_0, ..., j_{N-1}])
|
Chris@87
|
5738
|
Chris@87
|
5739 For `A` and `B` one-dimensional, this is equivalent to::
|
Chris@87
|
5740
|
Chris@87
|
5741 r = empty(len(A),len(B))
|
Chris@87
|
5742 for i in range(len(A)):
|
Chris@87
|
5743 for j in range(len(B)):
|
Chris@87
|
5744 r[i,j] = op(A[i], B[j]) # op = ufunc in question
|
Chris@87
|
5745
|
Chris@87
|
5746 Parameters
|
Chris@87
|
5747 ----------
|
Chris@87
|
5748 A : array_like
|
Chris@87
|
5749 First array
|
Chris@87
|
5750 B : array_like
|
Chris@87
|
5751 Second array
|
Chris@87
|
5752
|
Chris@87
|
5753 Returns
|
Chris@87
|
5754 -------
|
Chris@87
|
5755 r : ndarray
|
Chris@87
|
5756 Output array
|
Chris@87
|
5757
|
Chris@87
|
5758 See Also
|
Chris@87
|
5759 --------
|
Chris@87
|
5760 numpy.outer
|
Chris@87
|
5761
|
Chris@87
|
5762 Examples
|
Chris@87
|
5763 --------
|
Chris@87
|
5764 >>> np.multiply.outer([1, 2, 3], [4, 5, 6])
|
Chris@87
|
5765 array([[ 4, 5, 6],
|
Chris@87
|
5766 [ 8, 10, 12],
|
Chris@87
|
5767 [12, 15, 18]])
|
Chris@87
|
5768
|
Chris@87
|
5769 A multi-dimensional example:
|
Chris@87
|
5770
|
Chris@87
|
5771 >>> A = np.array([[1, 2, 3], [4, 5, 6]])
|
Chris@87
|
5772 >>> A.shape
|
Chris@87
|
5773 (2, 3)
|
Chris@87
|
5774 >>> B = np.array([[1, 2, 3, 4]])
|
Chris@87
|
5775 >>> B.shape
|
Chris@87
|
5776 (1, 4)
|
Chris@87
|
5777 >>> C = np.multiply.outer(A, B)
|
Chris@87
|
5778 >>> C.shape; C
|
Chris@87
|
5779 (2, 3, 1, 4)
|
Chris@87
|
5780 array([[[[ 1, 2, 3, 4]],
|
Chris@87
|
5781 [[ 2, 4, 6, 8]],
|
Chris@87
|
5782 [[ 3, 6, 9, 12]]],
|
Chris@87
|
5783 [[[ 4, 8, 12, 16]],
|
Chris@87
|
5784 [[ 5, 10, 15, 20]],
|
Chris@87
|
5785 [[ 6, 12, 18, 24]]]])
|
Chris@87
|
5786
|
Chris@87
|
5787 """))
|
Chris@87
|
5788
|
Chris@87
|
5789 add_newdoc('numpy.core', 'ufunc', ('at',
|
Chris@87
|
5790 """
|
Chris@87
|
5791 at(a, indices, b=None)
|
Chris@87
|
5792
|
Chris@87
|
5793 Performs unbuffered in place operation on operand 'a' for elements
|
Chris@87
|
5794 specified by 'indices'. For addition ufunc, this method is equivalent to
|
Chris@87
|
5795 `a[indices] += b`, except that results are accumulated for elements that
|
Chris@87
|
5796 are indexed more than once. For example, `a[[0,0]] += 1` will only
|
Chris@87
|
5797 increment the first element once because of buffering, whereas
|
Chris@87
|
5798 `add.at(a, [0,0], 1)` will increment the first element twice.
|
Chris@87
|
5799
|
Chris@87
|
5800 .. versionadded:: 1.8.0
|
Chris@87
|
5801
|
Chris@87
|
5802 Parameters
|
Chris@87
|
5803 ----------
|
Chris@87
|
5804 a : array_like
|
Chris@87
|
5805 The array to perform in place operation on.
|
Chris@87
|
5806 indices : array_like or tuple
|
Chris@87
|
5807 Array like index object or slice object for indexing into first
|
Chris@87
|
5808 operand. If first operand has multiple dimensions, indices can be a
|
Chris@87
|
5809 tuple of array like index objects or slice objects.
|
Chris@87
|
5810 b : array_like
|
Chris@87
|
5811 Second operand for ufuncs requiring two operands. Operand must be
|
Chris@87
|
5812 broadcastable over first operand after indexing or slicing.
|
Chris@87
|
5813
|
Chris@87
|
5814 Examples
|
Chris@87
|
5815 --------
|
Chris@87
|
5816 Set items 0 and 1 to their negative values:
|
Chris@87
|
5817
|
Chris@87
|
5818 >>> a = np.array([1, 2, 3, 4])
|
Chris@87
|
5819 >>> np.negative.at(a, [0, 1])
|
Chris@87
|
5820 >>> print(a)
|
Chris@87
|
5821 array([-1, -2, 3, 4])
|
Chris@87
|
5822
|
Chris@87
|
5823 ::
|
Chris@87
|
5824
|
Chris@87
|
5825 Increment items 0 and 1, and increment item 2 twice:
|
Chris@87
|
5826
|
Chris@87
|
5827 >>> a = np.array([1, 2, 3, 4])
|
Chris@87
|
5828 >>> np.add.at(a, [0, 1, 2, 2], 1)
|
Chris@87
|
5829 >>> print(a)
|
Chris@87
|
5830 array([2, 3, 5, 4])
|
Chris@87
|
5831
|
Chris@87
|
5832 ::
|
Chris@87
|
5833
|
Chris@87
|
5834 Add items 0 and 1 in first array to second array,
|
Chris@87
|
5835 and store results in first array:
|
Chris@87
|
5836
|
Chris@87
|
5837 >>> a = np.array([1, 2, 3, 4])
|
Chris@87
|
5838 >>> b = np.array([1, 2])
|
Chris@87
|
5839 >>> np.add.at(a, [0, 1], b)
|
Chris@87
|
5840 >>> print(a)
|
Chris@87
|
5841 array([2, 4, 3, 4])
|
Chris@87
|
5842
|
Chris@87
|
5843 """))
|
Chris@87
|
5844
|
Chris@87
|
5845 ##############################################################################
|
Chris@87
|
5846 #
|
Chris@87
|
5847 # Documentation for dtype attributes and methods
|
Chris@87
|
5848 #
|
Chris@87
|
5849 ##############################################################################
|
Chris@87
|
5850
|
Chris@87
|
5851 ##############################################################################
|
Chris@87
|
5852 #
|
Chris@87
|
5853 # dtype object
|
Chris@87
|
5854 #
|
Chris@87
|
5855 ##############################################################################
|
Chris@87
|
5856
|
Chris@87
|
5857 add_newdoc('numpy.core.multiarray', 'dtype',
|
Chris@87
|
5858 """
|
Chris@87
|
5859 dtype(obj, align=False, copy=False)
|
Chris@87
|
5860
|
Chris@87
|
5861 Create a data type object.
|
Chris@87
|
5862
|
Chris@87
|
5863 A numpy array is homogeneous, and contains elements described by a
|
Chris@87
|
5864 dtype object. A dtype object can be constructed from different
|
Chris@87
|
5865 combinations of fundamental numeric types.
|
Chris@87
|
5866
|
Chris@87
|
5867 Parameters
|
Chris@87
|
5868 ----------
|
Chris@87
|
5869 obj
|
Chris@87
|
5870 Object to be converted to a data type object.
|
Chris@87
|
5871 align : bool, optional
|
Chris@87
|
5872 Add padding to the fields to match what a C compiler would output
|
Chris@87
|
5873 for a similar C-struct. Can be ``True`` only if `obj` is a dictionary
|
Chris@87
|
5874 or a comma-separated string. If a struct dtype is being created,
|
Chris@87
|
5875 this also sets a sticky alignment flag ``isalignedstruct``.
|
Chris@87
|
5876 copy : bool, optional
|
Chris@87
|
5877 Make a new copy of the data-type object. If ``False``, the result
|
Chris@87
|
5878 may just be a reference to a built-in data-type object.
|
Chris@87
|
5879
|
Chris@87
|
5880 See also
|
Chris@87
|
5881 --------
|
Chris@87
|
5882 result_type
|
Chris@87
|
5883
|
Chris@87
|
5884 Examples
|
Chris@87
|
5885 --------
|
Chris@87
|
5886 Using array-scalar type:
|
Chris@87
|
5887
|
Chris@87
|
5888 >>> np.dtype(np.int16)
|
Chris@87
|
5889 dtype('int16')
|
Chris@87
|
5890
|
Chris@87
|
5891 Record, one field name 'f1', containing int16:
|
Chris@87
|
5892
|
Chris@87
|
5893 >>> np.dtype([('f1', np.int16)])
|
Chris@87
|
5894 dtype([('f1', '<i2')])
|
Chris@87
|
5895
|
Chris@87
|
5896 Record, one field named 'f1', in itself containing a record with one field:
|
Chris@87
|
5897
|
Chris@87
|
5898 >>> np.dtype([('f1', [('f1', np.int16)])])
|
Chris@87
|
5899 dtype([('f1', [('f1', '<i2')])])
|
Chris@87
|
5900
|
Chris@87
|
5901 Record, two fields: the first field contains an unsigned int, the
|
Chris@87
|
5902 second an int32:
|
Chris@87
|
5903
|
Chris@87
|
5904 >>> np.dtype([('f1', np.uint), ('f2', np.int32)])
|
Chris@87
|
5905 dtype([('f1', '<u4'), ('f2', '<i4')])
|
Chris@87
|
5906
|
Chris@87
|
5907 Using array-protocol type strings:
|
Chris@87
|
5908
|
Chris@87
|
5909 >>> np.dtype([('a','f8'),('b','S10')])
|
Chris@87
|
5910 dtype([('a', '<f8'), ('b', '|S10')])
|
Chris@87
|
5911
|
Chris@87
|
5912 Using comma-separated field formats. The shape is (2,3):
|
Chris@87
|
5913
|
Chris@87
|
5914 >>> np.dtype("i4, (2,3)f8")
|
Chris@87
|
5915 dtype([('f0', '<i4'), ('f1', '<f8', (2, 3))])
|
Chris@87
|
5916
|
Chris@87
|
5917 Using tuples. ``int`` is a fixed type, 3 the field's shape. ``void``
|
Chris@87
|
5918 is a flexible type, here of size 10:
|
Chris@87
|
5919
|
Chris@87
|
5920 >>> np.dtype([('hello',(np.int,3)),('world',np.void,10)])
|
Chris@87
|
5921 dtype([('hello', '<i4', 3), ('world', '|V10')])
|
Chris@87
|
5922
|
Chris@87
|
5923 Subdivide ``int16`` into 2 ``int8``'s, called x and y. 0 and 1 are
|
Chris@87
|
5924 the offsets in bytes:
|
Chris@87
|
5925
|
Chris@87
|
5926 >>> np.dtype((np.int16, {'x':(np.int8,0), 'y':(np.int8,1)}))
|
Chris@87
|
5927 dtype(('<i2', [('x', '|i1'), ('y', '|i1')]))
|
Chris@87
|
5928
|
Chris@87
|
5929 Using dictionaries. Two fields named 'gender' and 'age':
|
Chris@87
|
5930
|
Chris@87
|
5931 >>> np.dtype({'names':['gender','age'], 'formats':['S1',np.uint8]})
|
Chris@87
|
5932 dtype([('gender', '|S1'), ('age', '|u1')])
|
Chris@87
|
5933
|
Chris@87
|
5934 Offsets in bytes, here 0 and 25:
|
Chris@87
|
5935
|
Chris@87
|
5936 >>> np.dtype({'surname':('S25',0),'age':(np.uint8,25)})
|
Chris@87
|
5937 dtype([('surname', '|S25'), ('age', '|u1')])
|
Chris@87
|
5938
|
Chris@87
|
5939 """)
|
Chris@87
|
5940
|
Chris@87
|
5941 ##############################################################################
|
Chris@87
|
5942 #
|
Chris@87
|
5943 # dtype attributes
|
Chris@87
|
5944 #
|
Chris@87
|
5945 ##############################################################################
|
Chris@87
|
5946
|
Chris@87
|
5947 add_newdoc('numpy.core.multiarray', 'dtype', ('alignment',
|
Chris@87
|
5948 """
|
Chris@87
|
5949 The required alignment (bytes) of this data-type according to the compiler.
|
Chris@87
|
5950
|
Chris@87
|
5951 More information is available in the C-API section of the manual.
|
Chris@87
|
5952
|
Chris@87
|
5953 """))
|
Chris@87
|
5954
|
Chris@87
|
5955 add_newdoc('numpy.core.multiarray', 'dtype', ('byteorder',
|
Chris@87
|
5956 """
|
Chris@87
|
5957 A character indicating the byte-order of this data-type object.
|
Chris@87
|
5958
|
Chris@87
|
5959 One of:
|
Chris@87
|
5960
|
Chris@87
|
5961 === ==============
|
Chris@87
|
5962 '=' native
|
Chris@87
|
5963 '<' little-endian
|
Chris@87
|
5964 '>' big-endian
|
Chris@87
|
5965 '|' not applicable
|
Chris@87
|
5966 === ==============
|
Chris@87
|
5967
|
Chris@87
|
5968 All built-in data-type objects have byteorder either '=' or '|'.
|
Chris@87
|
5969
|
Chris@87
|
5970 Examples
|
Chris@87
|
5971 --------
|
Chris@87
|
5972
|
Chris@87
|
5973 >>> dt = np.dtype('i2')
|
Chris@87
|
5974 >>> dt.byteorder
|
Chris@87
|
5975 '='
|
Chris@87
|
5976 >>> # endian is not relevant for 8 bit numbers
|
Chris@87
|
5977 >>> np.dtype('i1').byteorder
|
Chris@87
|
5978 '|'
|
Chris@87
|
5979 >>> # or ASCII strings
|
Chris@87
|
5980 >>> np.dtype('S2').byteorder
|
Chris@87
|
5981 '|'
|
Chris@87
|
5982 >>> # Even if specific code is given, and it is native
|
Chris@87
|
5983 >>> # '=' is the byteorder
|
Chris@87
|
5984 >>> import sys
|
Chris@87
|
5985 >>> sys_is_le = sys.byteorder == 'little'
|
Chris@87
|
5986 >>> native_code = sys_is_le and '<' or '>'
|
Chris@87
|
5987 >>> swapped_code = sys_is_le and '>' or '<'
|
Chris@87
|
5988 >>> dt = np.dtype(native_code + 'i2')
|
Chris@87
|
5989 >>> dt.byteorder
|
Chris@87
|
5990 '='
|
Chris@87
|
5991 >>> # Swapped code shows up as itself
|
Chris@87
|
5992 >>> dt = np.dtype(swapped_code + 'i2')
|
Chris@87
|
5993 >>> dt.byteorder == swapped_code
|
Chris@87
|
5994 True
|
Chris@87
|
5995
|
Chris@87
|
5996 """))
|
Chris@87
|
5997
|
Chris@87
|
5998 add_newdoc('numpy.core.multiarray', 'dtype', ('char',
|
Chris@87
|
5999 """A unique character code for each of the 21 different built-in types."""))
|
Chris@87
|
6000
|
Chris@87
|
6001 add_newdoc('numpy.core.multiarray', 'dtype', ('descr',
|
Chris@87
|
6002 """
|
Chris@87
|
6003 Array-interface compliant full description of the data-type.
|
Chris@87
|
6004
|
Chris@87
|
6005 The format is that required by the 'descr' key in the
|
Chris@87
|
6006 `__array_interface__` attribute.
|
Chris@87
|
6007
|
Chris@87
|
6008 """))
|
Chris@87
|
6009
|
Chris@87
|
6010 add_newdoc('numpy.core.multiarray', 'dtype', ('fields',
|
Chris@87
|
6011 """
|
Chris@87
|
6012 Dictionary of named fields defined for this data type, or ``None``.
|
Chris@87
|
6013
|
Chris@87
|
6014 The dictionary is indexed by keys that are the names of the fields.
|
Chris@87
|
6015 Each entry in the dictionary is a tuple fully describing the field::
|
Chris@87
|
6016
|
Chris@87
|
6017 (dtype, offset[, title])
|
Chris@87
|
6018
|
Chris@87
|
6019 If present, the optional title can be any object (if it is a string
|
Chris@87
|
6020 or unicode then it will also be a key in the fields dictionary,
|
Chris@87
|
6021 otherwise it's meta-data). Notice also that the first two elements
|
Chris@87
|
6022 of the tuple can be passed directly as arguments to the ``ndarray.getfield``
|
Chris@87
|
6023 and ``ndarray.setfield`` methods.
|
Chris@87
|
6024
|
Chris@87
|
6025 See Also
|
Chris@87
|
6026 --------
|
Chris@87
|
6027 ndarray.getfield, ndarray.setfield
|
Chris@87
|
6028
|
Chris@87
|
6029 Examples
|
Chris@87
|
6030 --------
|
Chris@87
|
6031 >>> dt = np.dtype([('name', np.str_, 16), ('grades', np.float64, (2,))])
|
Chris@87
|
6032 >>> print dt.fields
|
Chris@87
|
6033 {'grades': (dtype(('float64',(2,))), 16), 'name': (dtype('|S16'), 0)}
|
Chris@87
|
6034
|
Chris@87
|
6035 """))
|
Chris@87
|
6036
|
Chris@87
|
6037 add_newdoc('numpy.core.multiarray', 'dtype', ('flags',
|
Chris@87
|
6038 """
|
Chris@87
|
6039 Bit-flags describing how this data type is to be interpreted.
|
Chris@87
|
6040
|
Chris@87
|
6041 Bit-masks are in `numpy.core.multiarray` as the constants
|
Chris@87
|
6042 `ITEM_HASOBJECT`, `LIST_PICKLE`, `ITEM_IS_POINTER`, `NEEDS_INIT`,
|
Chris@87
|
6043 `NEEDS_PYAPI`, `USE_GETITEM`, `USE_SETITEM`. A full explanation
|
Chris@87
|
6044 of these flags is in C-API documentation; they are largely useful
|
Chris@87
|
6045 for user-defined data-types.
|
Chris@87
|
6046
|
Chris@87
|
6047 """))
|
Chris@87
|
6048
|
Chris@87
|
6049 add_newdoc('numpy.core.multiarray', 'dtype', ('hasobject',
|
Chris@87
|
6050 """
|
Chris@87
|
6051 Boolean indicating whether this dtype contains any reference-counted
|
Chris@87
|
6052 objects in any fields or sub-dtypes.
|
Chris@87
|
6053
|
Chris@87
|
6054 Recall that what is actually in the ndarray memory representing
|
Chris@87
|
6055 the Python object is the memory address of that object (a pointer).
|
Chris@87
|
6056 Special handling may be required, and this attribute is useful for
|
Chris@87
|
6057 distinguishing data types that may contain arbitrary Python objects
|
Chris@87
|
6058 and data-types that won't.
|
Chris@87
|
6059
|
Chris@87
|
6060 """))
|
Chris@87
|
6061
|
Chris@87
|
6062 add_newdoc('numpy.core.multiarray', 'dtype', ('isbuiltin',
|
Chris@87
|
6063 """
|
Chris@87
|
6064 Integer indicating how this dtype relates to the built-in dtypes.
|
Chris@87
|
6065
|
Chris@87
|
6066 Read-only.
|
Chris@87
|
6067
|
Chris@87
|
6068 = ========================================================================
|
Chris@87
|
6069 0 if this is a structured array type, with fields
|
Chris@87
|
6070 1 if this is a dtype compiled into numpy (such as ints, floats etc)
|
Chris@87
|
6071 2 if the dtype is for a user-defined numpy type
|
Chris@87
|
6072 A user-defined type uses the numpy C-API machinery to extend
|
Chris@87
|
6073 numpy to handle a new array type. See
|
Chris@87
|
6074 :ref:`user.user-defined-data-types` in the Numpy manual.
|
Chris@87
|
6075 = ========================================================================
|
Chris@87
|
6076
|
Chris@87
|
6077 Examples
|
Chris@87
|
6078 --------
|
Chris@87
|
6079 >>> dt = np.dtype('i2')
|
Chris@87
|
6080 >>> dt.isbuiltin
|
Chris@87
|
6081 1
|
Chris@87
|
6082 >>> dt = np.dtype('f8')
|
Chris@87
|
6083 >>> dt.isbuiltin
|
Chris@87
|
6084 1
|
Chris@87
|
6085 >>> dt = np.dtype([('field1', 'f8')])
|
Chris@87
|
6086 >>> dt.isbuiltin
|
Chris@87
|
6087 0
|
Chris@87
|
6088
|
Chris@87
|
6089 """))
|
Chris@87
|
6090
|
Chris@87
|
6091 add_newdoc('numpy.core.multiarray', 'dtype', ('isnative',
|
Chris@87
|
6092 """
|
Chris@87
|
6093 Boolean indicating whether the byte order of this dtype is native
|
Chris@87
|
6094 to the platform.
|
Chris@87
|
6095
|
Chris@87
|
6096 """))
|
Chris@87
|
6097
|
Chris@87
|
6098 add_newdoc('numpy.core.multiarray', 'dtype', ('isalignedstruct',
|
Chris@87
|
6099 """
|
Chris@87
|
6100 Boolean indicating whether the dtype is a struct which maintains
|
Chris@87
|
6101 field alignment. This flag is sticky, so when combining multiple
|
Chris@87
|
6102 structs together, it is preserved and produces new dtypes which
|
Chris@87
|
6103 are also aligned.
|
Chris@87
|
6104 """))
|
Chris@87
|
6105
|
Chris@87
|
6106 add_newdoc('numpy.core.multiarray', 'dtype', ('itemsize',
|
Chris@87
|
6107 """
|
Chris@87
|
6108 The element size of this data-type object.
|
Chris@87
|
6109
|
Chris@87
|
6110 For 18 of the 21 types this number is fixed by the data-type.
|
Chris@87
|
6111 For the flexible data-types, this number can be anything.
|
Chris@87
|
6112
|
Chris@87
|
6113 """))
|
Chris@87
|
6114
|
Chris@87
|
6115 add_newdoc('numpy.core.multiarray', 'dtype', ('kind',
|
Chris@87
|
6116 """
|
Chris@87
|
6117 A character code (one of 'biufcOSUV') identifying the general kind of data.
|
Chris@87
|
6118
|
Chris@87
|
6119 = ======================
|
Chris@87
|
6120 b boolean
|
Chris@87
|
6121 i signed integer
|
Chris@87
|
6122 u unsigned integer
|
Chris@87
|
6123 f floating-point
|
Chris@87
|
6124 c complex floating-point
|
Chris@87
|
6125 O object
|
Chris@87
|
6126 S (byte-)string
|
Chris@87
|
6127 U Unicode
|
Chris@87
|
6128 V void
|
Chris@87
|
6129 = ======================
|
Chris@87
|
6130
|
Chris@87
|
6131 """))
|
Chris@87
|
6132
|
Chris@87
|
6133 add_newdoc('numpy.core.multiarray', 'dtype', ('name',
|
Chris@87
|
6134 """
|
Chris@87
|
6135 A bit-width name for this data-type.
|
Chris@87
|
6136
|
Chris@87
|
6137 Un-sized flexible data-type objects do not have this attribute.
|
Chris@87
|
6138
|
Chris@87
|
6139 """))
|
Chris@87
|
6140
|
Chris@87
|
6141 add_newdoc('numpy.core.multiarray', 'dtype', ('names',
|
Chris@87
|
6142 """
|
Chris@87
|
6143 Ordered list of field names, or ``None`` if there are no fields.
|
Chris@87
|
6144
|
Chris@87
|
6145 The names are ordered according to increasing byte offset. This can be
|
Chris@87
|
6146 used, for example, to walk through all of the named fields in offset order.
|
Chris@87
|
6147
|
Chris@87
|
6148 Examples
|
Chris@87
|
6149 --------
|
Chris@87
|
6150 >>> dt = np.dtype([('name', np.str_, 16), ('grades', np.float64, (2,))])
|
Chris@87
|
6151 >>> dt.names
|
Chris@87
|
6152 ('name', 'grades')
|
Chris@87
|
6153
|
Chris@87
|
6154 """))
|
Chris@87
|
6155
|
Chris@87
|
6156 add_newdoc('numpy.core.multiarray', 'dtype', ('num',
|
Chris@87
|
6157 """
|
Chris@87
|
6158 A unique number for each of the 21 different built-in types.
|
Chris@87
|
6159
|
Chris@87
|
6160 These are roughly ordered from least-to-most precision.
|
Chris@87
|
6161
|
Chris@87
|
6162 """))
|
Chris@87
|
6163
|
Chris@87
|
6164 add_newdoc('numpy.core.multiarray', 'dtype', ('shape',
|
Chris@87
|
6165 """
|
Chris@87
|
6166 Shape tuple of the sub-array if this data type describes a sub-array,
|
Chris@87
|
6167 and ``()`` otherwise.
|
Chris@87
|
6168
|
Chris@87
|
6169 """))
|
Chris@87
|
6170
|
Chris@87
|
6171 add_newdoc('numpy.core.multiarray', 'dtype', ('str',
|
Chris@87
|
6172 """The array-protocol typestring of this data-type object."""))
|
Chris@87
|
6173
|
Chris@87
|
6174 add_newdoc('numpy.core.multiarray', 'dtype', ('subdtype',
|
Chris@87
|
6175 """
|
Chris@87
|
6176 Tuple ``(item_dtype, shape)`` if this `dtype` describes a sub-array, and
|
Chris@87
|
6177 None otherwise.
|
Chris@87
|
6178
|
Chris@87
|
6179 The *shape* is the fixed shape of the sub-array described by this
|
Chris@87
|
6180 data type, and *item_dtype* the data type of the array.
|
Chris@87
|
6181
|
Chris@87
|
6182 If a field whose dtype object has this attribute is retrieved,
|
Chris@87
|
6183 then the extra dimensions implied by *shape* are tacked on to
|
Chris@87
|
6184 the end of the retrieved array.
|
Chris@87
|
6185
|
Chris@87
|
6186 """))
|
Chris@87
|
6187
|
Chris@87
|
6188 add_newdoc('numpy.core.multiarray', 'dtype', ('type',
|
Chris@87
|
6189 """The type object used to instantiate a scalar of this data-type."""))
|
Chris@87
|
6190
|
Chris@87
|
6191 ##############################################################################
|
Chris@87
|
6192 #
|
Chris@87
|
6193 # dtype methods
|
Chris@87
|
6194 #
|
Chris@87
|
6195 ##############################################################################
|
Chris@87
|
6196
|
Chris@87
|
6197 add_newdoc('numpy.core.multiarray', 'dtype', ('newbyteorder',
|
Chris@87
|
6198 """
|
Chris@87
|
6199 newbyteorder(new_order='S')
|
Chris@87
|
6200
|
Chris@87
|
6201 Return a new dtype with a different byte order.
|
Chris@87
|
6202
|
Chris@87
|
6203 Changes are also made in all fields and sub-arrays of the data type.
|
Chris@87
|
6204
|
Chris@87
|
6205 Parameters
|
Chris@87
|
6206 ----------
|
Chris@87
|
6207 new_order : string, optional
|
Chris@87
|
6208 Byte order to force; a value from the byte order
|
Chris@87
|
6209 specifications below. The default value ('S') results in
|
Chris@87
|
6210 swapping the current byte order.
|
Chris@87
|
6211 `new_order` codes can be any of::
|
Chris@87
|
6212
|
Chris@87
|
6213 * 'S' - swap dtype from current to opposite endian
|
Chris@87
|
6214 * {'<', 'L'} - little endian
|
Chris@87
|
6215 * {'>', 'B'} - big endian
|
Chris@87
|
6216 * {'=', 'N'} - native order
|
Chris@87
|
6217 * {'|', 'I'} - ignore (no change to byte order)
|
Chris@87
|
6218
|
Chris@87
|
6219 The code does a case-insensitive check on the first letter of
|
Chris@87
|
6220 `new_order` for these alternatives. For example, any of '>'
|
Chris@87
|
6221 or 'B' or 'b' or 'brian' are valid to specify big-endian.
|
Chris@87
|
6222
|
Chris@87
|
6223 Returns
|
Chris@87
|
6224 -------
|
Chris@87
|
6225 new_dtype : dtype
|
Chris@87
|
6226 New dtype object with the given change to the byte order.
|
Chris@87
|
6227
|
Chris@87
|
6228 Notes
|
Chris@87
|
6229 -----
|
Chris@87
|
6230 Changes are also made in all fields and sub-arrays of the data type.
|
Chris@87
|
6231
|
Chris@87
|
6232 Examples
|
Chris@87
|
6233 --------
|
Chris@87
|
6234 >>> import sys
|
Chris@87
|
6235 >>> sys_is_le = sys.byteorder == 'little'
|
Chris@87
|
6236 >>> native_code = sys_is_le and '<' or '>'
|
Chris@87
|
6237 >>> swapped_code = sys_is_le and '>' or '<'
|
Chris@87
|
6238 >>> native_dt = np.dtype(native_code+'i2')
|
Chris@87
|
6239 >>> swapped_dt = np.dtype(swapped_code+'i2')
|
Chris@87
|
6240 >>> native_dt.newbyteorder('S') == swapped_dt
|
Chris@87
|
6241 True
|
Chris@87
|
6242 >>> native_dt.newbyteorder() == swapped_dt
|
Chris@87
|
6243 True
|
Chris@87
|
6244 >>> native_dt == swapped_dt.newbyteorder('S')
|
Chris@87
|
6245 True
|
Chris@87
|
6246 >>> native_dt == swapped_dt.newbyteorder('=')
|
Chris@87
|
6247 True
|
Chris@87
|
6248 >>> native_dt == swapped_dt.newbyteorder('N')
|
Chris@87
|
6249 True
|
Chris@87
|
6250 >>> native_dt == native_dt.newbyteorder('|')
|
Chris@87
|
6251 True
|
Chris@87
|
6252 >>> np.dtype('<i2') == native_dt.newbyteorder('<')
|
Chris@87
|
6253 True
|
Chris@87
|
6254 >>> np.dtype('<i2') == native_dt.newbyteorder('L')
|
Chris@87
|
6255 True
|
Chris@87
|
6256 >>> np.dtype('>i2') == native_dt.newbyteorder('>')
|
Chris@87
|
6257 True
|
Chris@87
|
6258 >>> np.dtype('>i2') == native_dt.newbyteorder('B')
|
Chris@87
|
6259 True
|
Chris@87
|
6260
|
Chris@87
|
6261 """))
|
Chris@87
|
6262
|
Chris@87
|
6263
|
Chris@87
|
6264 ##############################################################################
|
Chris@87
|
6265 #
|
Chris@87
|
6266 # Datetime-related Methods
|
Chris@87
|
6267 #
|
Chris@87
|
6268 ##############################################################################
|
Chris@87
|
6269
|
Chris@87
|
6270 add_newdoc('numpy.core.multiarray', 'busdaycalendar',
|
Chris@87
|
6271 """
|
Chris@87
|
6272 busdaycalendar(weekmask='1111100', holidays=None)
|
Chris@87
|
6273
|
Chris@87
|
6274 A business day calendar object that efficiently stores information
|
Chris@87
|
6275 defining valid days for the busday family of functions.
|
Chris@87
|
6276
|
Chris@87
|
6277 The default valid days are Monday through Friday ("business days").
|
Chris@87
|
6278 A busdaycalendar object can be specified with any set of weekly
|
Chris@87
|
6279 valid days, plus an optional "holiday" dates that always will be invalid.
|
Chris@87
|
6280
|
Chris@87
|
6281 Once a busdaycalendar object is created, the weekmask and holidays
|
Chris@87
|
6282 cannot be modified.
|
Chris@87
|
6283
|
Chris@87
|
6284 .. versionadded:: 1.7.0
|
Chris@87
|
6285
|
Chris@87
|
6286 Parameters
|
Chris@87
|
6287 ----------
|
Chris@87
|
6288 weekmask : str or array_like of bool, optional
|
Chris@87
|
6289 A seven-element array indicating which of Monday through Sunday are
|
Chris@87
|
6290 valid days. May be specified as a length-seven list or array, like
|
Chris@87
|
6291 [1,1,1,1,1,0,0]; a length-seven string, like '1111100'; or a string
|
Chris@87
|
6292 like "Mon Tue Wed Thu Fri", made up of 3-character abbreviations for
|
Chris@87
|
6293 weekdays, optionally separated by white space. Valid abbreviations
|
Chris@87
|
6294 are: Mon Tue Wed Thu Fri Sat Sun
|
Chris@87
|
6295 holidays : array_like of datetime64[D], optional
|
Chris@87
|
6296 An array of dates to consider as invalid dates, no matter which
|
Chris@87
|
6297 weekday they fall upon. Holiday dates may be specified in any
|
Chris@87
|
6298 order, and NaT (not-a-time) dates are ignored. This list is
|
Chris@87
|
6299 saved in a normalized form that is suited for fast calculations
|
Chris@87
|
6300 of valid days.
|
Chris@87
|
6301
|
Chris@87
|
6302 Returns
|
Chris@87
|
6303 -------
|
Chris@87
|
6304 out : busdaycalendar
|
Chris@87
|
6305 A business day calendar object containing the specified
|
Chris@87
|
6306 weekmask and holidays values.
|
Chris@87
|
6307
|
Chris@87
|
6308 See Also
|
Chris@87
|
6309 --------
|
Chris@87
|
6310 is_busday : Returns a boolean array indicating valid days.
|
Chris@87
|
6311 busday_offset : Applies an offset counted in valid days.
|
Chris@87
|
6312 busday_count : Counts how many valid days are in a half-open date range.
|
Chris@87
|
6313
|
Chris@87
|
6314 Attributes
|
Chris@87
|
6315 ----------
|
Chris@87
|
6316 Note: once a busdaycalendar object is created, you cannot modify the
|
Chris@87
|
6317 weekmask or holidays. The attributes return copies of internal data.
|
Chris@87
|
6318 weekmask : (copy) seven-element array of bool
|
Chris@87
|
6319 holidays : (copy) sorted array of datetime64[D]
|
Chris@87
|
6320
|
Chris@87
|
6321 Examples
|
Chris@87
|
6322 --------
|
Chris@87
|
6323 >>> # Some important days in July
|
Chris@87
|
6324 ... bdd = np.busdaycalendar(
|
Chris@87
|
6325 ... holidays=['2011-07-01', '2011-07-04', '2011-07-17'])
|
Chris@87
|
6326 >>> # Default is Monday to Friday weekdays
|
Chris@87
|
6327 ... bdd.weekmask
|
Chris@87
|
6328 array([ True, True, True, True, True, False, False], dtype='bool')
|
Chris@87
|
6329 >>> # Any holidays already on the weekend are removed
|
Chris@87
|
6330 ... bdd.holidays
|
Chris@87
|
6331 array(['2011-07-01', '2011-07-04'], dtype='datetime64[D]')
|
Chris@87
|
6332 """)
|
Chris@87
|
6333
|
Chris@87
|
6334 add_newdoc('numpy.core.multiarray', 'busdaycalendar', ('weekmask',
|
Chris@87
|
6335 """A copy of the seven-element boolean mask indicating valid days."""))
|
Chris@87
|
6336
|
Chris@87
|
6337 add_newdoc('numpy.core.multiarray', 'busdaycalendar', ('holidays',
|
Chris@87
|
6338 """A copy of the holiday array indicating additional invalid days."""))
|
Chris@87
|
6339
|
Chris@87
|
6340 add_newdoc('numpy.core.multiarray', 'is_busday',
|
Chris@87
|
6341 """
|
Chris@87
|
6342 is_busday(dates, weekmask='1111100', holidays=None, busdaycal=None, out=None)
|
Chris@87
|
6343
|
Chris@87
|
6344 Calculates which of the given dates are valid days, and which are not.
|
Chris@87
|
6345
|
Chris@87
|
6346 .. versionadded:: 1.7.0
|
Chris@87
|
6347
|
Chris@87
|
6348 Parameters
|
Chris@87
|
6349 ----------
|
Chris@87
|
6350 dates : array_like of datetime64[D]
|
Chris@87
|
6351 The array of dates to process.
|
Chris@87
|
6352 weekmask : str or array_like of bool, optional
|
Chris@87
|
6353 A seven-element array indicating which of Monday through Sunday are
|
Chris@87
|
6354 valid days. May be specified as a length-seven list or array, like
|
Chris@87
|
6355 [1,1,1,1,1,0,0]; a length-seven string, like '1111100'; or a string
|
Chris@87
|
6356 like "Mon Tue Wed Thu Fri", made up of 3-character abbreviations for
|
Chris@87
|
6357 weekdays, optionally separated by white space. Valid abbreviations
|
Chris@87
|
6358 are: Mon Tue Wed Thu Fri Sat Sun
|
Chris@87
|
6359 holidays : array_like of datetime64[D], optional
|
Chris@87
|
6360 An array of dates to consider as invalid dates. They may be
|
Chris@87
|
6361 specified in any order, and NaT (not-a-time) dates are ignored.
|
Chris@87
|
6362 This list is saved in a normalized form that is suited for
|
Chris@87
|
6363 fast calculations of valid days.
|
Chris@87
|
6364 busdaycal : busdaycalendar, optional
|
Chris@87
|
6365 A `busdaycalendar` object which specifies the valid days. If this
|
Chris@87
|
6366 parameter is provided, neither weekmask nor holidays may be
|
Chris@87
|
6367 provided.
|
Chris@87
|
6368 out : array of bool, optional
|
Chris@87
|
6369 If provided, this array is filled with the result.
|
Chris@87
|
6370
|
Chris@87
|
6371 Returns
|
Chris@87
|
6372 -------
|
Chris@87
|
6373 out : array of bool
|
Chris@87
|
6374 An array with the same shape as ``dates``, containing True for
|
Chris@87
|
6375 each valid day, and False for each invalid day.
|
Chris@87
|
6376
|
Chris@87
|
6377 See Also
|
Chris@87
|
6378 --------
|
Chris@87
|
6379 busdaycalendar: An object that specifies a custom set of valid days.
|
Chris@87
|
6380 busday_offset : Applies an offset counted in valid days.
|
Chris@87
|
6381 busday_count : Counts how many valid days are in a half-open date range.
|
Chris@87
|
6382
|
Chris@87
|
6383 Examples
|
Chris@87
|
6384 --------
|
Chris@87
|
6385 >>> # The weekdays are Friday, Saturday, and Monday
|
Chris@87
|
6386 ... np.is_busday(['2011-07-01', '2011-07-02', '2011-07-18'],
|
Chris@87
|
6387 ... holidays=['2011-07-01', '2011-07-04', '2011-07-17'])
|
Chris@87
|
6388 array([False, False, True], dtype='bool')
|
Chris@87
|
6389 """)
|
Chris@87
|
6390
|
Chris@87
|
6391 add_newdoc('numpy.core.multiarray', 'busday_offset',
|
Chris@87
|
6392 """
|
Chris@87
|
6393 busday_offset(dates, offsets, roll='raise', weekmask='1111100', holidays=None, busdaycal=None, out=None)
|
Chris@87
|
6394
|
Chris@87
|
6395 First adjusts the date to fall on a valid day according to
|
Chris@87
|
6396 the ``roll`` rule, then applies offsets to the given dates
|
Chris@87
|
6397 counted in valid days.
|
Chris@87
|
6398
|
Chris@87
|
6399 .. versionadded:: 1.7.0
|
Chris@87
|
6400
|
Chris@87
|
6401 Parameters
|
Chris@87
|
6402 ----------
|
Chris@87
|
6403 dates : array_like of datetime64[D]
|
Chris@87
|
6404 The array of dates to process.
|
Chris@87
|
6405 offsets : array_like of int
|
Chris@87
|
6406 The array of offsets, which is broadcast with ``dates``.
|
Chris@87
|
6407 roll : {'raise', 'nat', 'forward', 'following', 'backward', 'preceding', 'modifiedfollowing', 'modifiedpreceding'}, optional
|
Chris@87
|
6408 How to treat dates that do not fall on a valid day. The default
|
Chris@87
|
6409 is 'raise'.
|
Chris@87
|
6410
|
Chris@87
|
6411 * 'raise' means to raise an exception for an invalid day.
|
Chris@87
|
6412 * 'nat' means to return a NaT (not-a-time) for an invalid day.
|
Chris@87
|
6413 * 'forward' and 'following' mean to take the first valid day
|
Chris@87
|
6414 later in time.
|
Chris@87
|
6415 * 'backward' and 'preceding' mean to take the first valid day
|
Chris@87
|
6416 earlier in time.
|
Chris@87
|
6417 * 'modifiedfollowing' means to take the first valid day
|
Chris@87
|
6418 later in time unless it is across a Month boundary, in which
|
Chris@87
|
6419 case to take the first valid day earlier in time.
|
Chris@87
|
6420 * 'modifiedpreceding' means to take the first valid day
|
Chris@87
|
6421 earlier in time unless it is across a Month boundary, in which
|
Chris@87
|
6422 case to take the first valid day later in time.
|
Chris@87
|
6423 weekmask : str or array_like of bool, optional
|
Chris@87
|
6424 A seven-element array indicating which of Monday through Sunday are
|
Chris@87
|
6425 valid days. May be specified as a length-seven list or array, like
|
Chris@87
|
6426 [1,1,1,1,1,0,0]; a length-seven string, like '1111100'; or a string
|
Chris@87
|
6427 like "Mon Tue Wed Thu Fri", made up of 3-character abbreviations for
|
Chris@87
|
6428 weekdays, optionally separated by white space. Valid abbreviations
|
Chris@87
|
6429 are: Mon Tue Wed Thu Fri Sat Sun
|
Chris@87
|
6430 holidays : array_like of datetime64[D], optional
|
Chris@87
|
6431 An array of dates to consider as invalid dates. They may be
|
Chris@87
|
6432 specified in any order, and NaT (not-a-time) dates are ignored.
|
Chris@87
|
6433 This list is saved in a normalized form that is suited for
|
Chris@87
|
6434 fast calculations of valid days.
|
Chris@87
|
6435 busdaycal : busdaycalendar, optional
|
Chris@87
|
6436 A `busdaycalendar` object which specifies the valid days. If this
|
Chris@87
|
6437 parameter is provided, neither weekmask nor holidays may be
|
Chris@87
|
6438 provided.
|
Chris@87
|
6439 out : array of datetime64[D], optional
|
Chris@87
|
6440 If provided, this array is filled with the result.
|
Chris@87
|
6441
|
Chris@87
|
6442 Returns
|
Chris@87
|
6443 -------
|
Chris@87
|
6444 out : array of datetime64[D]
|
Chris@87
|
6445 An array with a shape from broadcasting ``dates`` and ``offsets``
|
Chris@87
|
6446 together, containing the dates with offsets applied.
|
Chris@87
|
6447
|
Chris@87
|
6448 See Also
|
Chris@87
|
6449 --------
|
Chris@87
|
6450 busdaycalendar: An object that specifies a custom set of valid days.
|
Chris@87
|
6451 is_busday : Returns a boolean array indicating valid days.
|
Chris@87
|
6452 busday_count : Counts how many valid days are in a half-open date range.
|
Chris@87
|
6453
|
Chris@87
|
6454 Examples
|
Chris@87
|
6455 --------
|
Chris@87
|
6456 >>> # First business day in October 2011 (not accounting for holidays)
|
Chris@87
|
6457 ... np.busday_offset('2011-10', 0, roll='forward')
|
Chris@87
|
6458 numpy.datetime64('2011-10-03','D')
|
Chris@87
|
6459 >>> # Last business day in February 2012 (not accounting for holidays)
|
Chris@87
|
6460 ... np.busday_offset('2012-03', -1, roll='forward')
|
Chris@87
|
6461 numpy.datetime64('2012-02-29','D')
|
Chris@87
|
6462 >>> # Third Wednesday in January 2011
|
Chris@87
|
6463 ... np.busday_offset('2011-01', 2, roll='forward', weekmask='Wed')
|
Chris@87
|
6464 numpy.datetime64('2011-01-19','D')
|
Chris@87
|
6465 >>> # 2012 Mother's Day in Canada and the U.S.
|
Chris@87
|
6466 ... np.busday_offset('2012-05', 1, roll='forward', weekmask='Sun')
|
Chris@87
|
6467 numpy.datetime64('2012-05-13','D')
|
Chris@87
|
6468
|
Chris@87
|
6469 >>> # First business day on or after a date
|
Chris@87
|
6470 ... np.busday_offset('2011-03-20', 0, roll='forward')
|
Chris@87
|
6471 numpy.datetime64('2011-03-21','D')
|
Chris@87
|
6472 >>> np.busday_offset('2011-03-22', 0, roll='forward')
|
Chris@87
|
6473 numpy.datetime64('2011-03-22','D')
|
Chris@87
|
6474 >>> # First business day after a date
|
Chris@87
|
6475 ... np.busday_offset('2011-03-20', 1, roll='backward')
|
Chris@87
|
6476 numpy.datetime64('2011-03-21','D')
|
Chris@87
|
6477 >>> np.busday_offset('2011-03-22', 1, roll='backward')
|
Chris@87
|
6478 numpy.datetime64('2011-03-23','D')
|
Chris@87
|
6479 """)
|
Chris@87
|
6480
|
Chris@87
|
6481 add_newdoc('numpy.core.multiarray', 'busday_count',
|
Chris@87
|
6482 """
|
Chris@87
|
6483 busday_count(begindates, enddates, weekmask='1111100', holidays=[], busdaycal=None, out=None)
|
Chris@87
|
6484
|
Chris@87
|
6485 Counts the number of valid days between `begindates` and
|
Chris@87
|
6486 `enddates`, not including the day of `enddates`.
|
Chris@87
|
6487
|
Chris@87
|
6488 If ``enddates`` specifies a date value that is earlier than the
|
Chris@87
|
6489 corresponding ``begindates`` date value, the count will be negative.
|
Chris@87
|
6490
|
Chris@87
|
6491 .. versionadded:: 1.7.0
|
Chris@87
|
6492
|
Chris@87
|
6493 Parameters
|
Chris@87
|
6494 ----------
|
Chris@87
|
6495 begindates : array_like of datetime64[D]
|
Chris@87
|
6496 The array of the first dates for counting.
|
Chris@87
|
6497 enddates : array_like of datetime64[D]
|
Chris@87
|
6498 The array of the end dates for counting, which are excluded
|
Chris@87
|
6499 from the count themselves.
|
Chris@87
|
6500 weekmask : str or array_like of bool, optional
|
Chris@87
|
6501 A seven-element array indicating which of Monday through Sunday are
|
Chris@87
|
6502 valid days. May be specified as a length-seven list or array, like
|
Chris@87
|
6503 [1,1,1,1,1,0,0]; a length-seven string, like '1111100'; or a string
|
Chris@87
|
6504 like "Mon Tue Wed Thu Fri", made up of 3-character abbreviations for
|
Chris@87
|
6505 weekdays, optionally separated by white space. Valid abbreviations
|
Chris@87
|
6506 are: Mon Tue Wed Thu Fri Sat Sun
|
Chris@87
|
6507 holidays : array_like of datetime64[D], optional
|
Chris@87
|
6508 An array of dates to consider as invalid dates. They may be
|
Chris@87
|
6509 specified in any order, and NaT (not-a-time) dates are ignored.
|
Chris@87
|
6510 This list is saved in a normalized form that is suited for
|
Chris@87
|
6511 fast calculations of valid days.
|
Chris@87
|
6512 busdaycal : busdaycalendar, optional
|
Chris@87
|
6513 A `busdaycalendar` object which specifies the valid days. If this
|
Chris@87
|
6514 parameter is provided, neither weekmask nor holidays may be
|
Chris@87
|
6515 provided.
|
Chris@87
|
6516 out : array of int, optional
|
Chris@87
|
6517 If provided, this array is filled with the result.
|
Chris@87
|
6518
|
Chris@87
|
6519 Returns
|
Chris@87
|
6520 -------
|
Chris@87
|
6521 out : array of int
|
Chris@87
|
6522 An array with a shape from broadcasting ``begindates`` and ``enddates``
|
Chris@87
|
6523 together, containing the number of valid days between
|
Chris@87
|
6524 the begin and end dates.
|
Chris@87
|
6525
|
Chris@87
|
6526 See Also
|
Chris@87
|
6527 --------
|
Chris@87
|
6528 busdaycalendar: An object that specifies a custom set of valid days.
|
Chris@87
|
6529 is_busday : Returns a boolean array indicating valid days.
|
Chris@87
|
6530 busday_offset : Applies an offset counted in valid days.
|
Chris@87
|
6531
|
Chris@87
|
6532 Examples
|
Chris@87
|
6533 --------
|
Chris@87
|
6534 >>> # Number of weekdays in January 2011
|
Chris@87
|
6535 ... np.busday_count('2011-01', '2011-02')
|
Chris@87
|
6536 21
|
Chris@87
|
6537 >>> # Number of weekdays in 2011
|
Chris@87
|
6538 ... np.busday_count('2011', '2012')
|
Chris@87
|
6539 260
|
Chris@87
|
6540 >>> # Number of Saturdays in 2011
|
Chris@87
|
6541 ... np.busday_count('2011', '2012', weekmask='Sat')
|
Chris@87
|
6542 53
|
Chris@87
|
6543 """)
|
Chris@87
|
6544
|
Chris@87
|
6545 ##############################################################################
|
Chris@87
|
6546 #
|
Chris@87
|
6547 # nd_grid instances
|
Chris@87
|
6548 #
|
Chris@87
|
6549 ##############################################################################
|
Chris@87
|
6550
|
Chris@87
|
6551 add_newdoc('numpy.lib.index_tricks', 'mgrid',
|
Chris@87
|
6552 """
|
Chris@87
|
6553 `nd_grid` instance which returns a dense multi-dimensional "meshgrid".
|
Chris@87
|
6554
|
Chris@87
|
6555 An instance of `numpy.lib.index_tricks.nd_grid` which returns an dense
|
Chris@87
|
6556 (or fleshed out) mesh-grid when indexed, so that each returned argument
|
Chris@87
|
6557 has the same shape. The dimensions and number of the output arrays are
|
Chris@87
|
6558 equal to the number of indexing dimensions. If the step length is not a
|
Chris@87
|
6559 complex number, then the stop is not inclusive.
|
Chris@87
|
6560
|
Chris@87
|
6561 However, if the step length is a **complex number** (e.g. 5j), then
|
Chris@87
|
6562 the integer part of its magnitude is interpreted as specifying the
|
Chris@87
|
6563 number of points to create between the start and stop values, where
|
Chris@87
|
6564 the stop value **is inclusive**.
|
Chris@87
|
6565
|
Chris@87
|
6566 Returns
|
Chris@87
|
6567 ----------
|
Chris@87
|
6568 mesh-grid `ndarrays` all of the same dimensions
|
Chris@87
|
6569
|
Chris@87
|
6570 See Also
|
Chris@87
|
6571 --------
|
Chris@87
|
6572 numpy.lib.index_tricks.nd_grid : class of `ogrid` and `mgrid` objects
|
Chris@87
|
6573 ogrid : like mgrid but returns open (not fleshed out) mesh grids
|
Chris@87
|
6574 r_ : array concatenator
|
Chris@87
|
6575
|
Chris@87
|
6576 Examples
|
Chris@87
|
6577 --------
|
Chris@87
|
6578 >>> np.mgrid[0:5,0:5]
|
Chris@87
|
6579 array([[[0, 0, 0, 0, 0],
|
Chris@87
|
6580 [1, 1, 1, 1, 1],
|
Chris@87
|
6581 [2, 2, 2, 2, 2],
|
Chris@87
|
6582 [3, 3, 3, 3, 3],
|
Chris@87
|
6583 [4, 4, 4, 4, 4]],
|
Chris@87
|
6584 [[0, 1, 2, 3, 4],
|
Chris@87
|
6585 [0, 1, 2, 3, 4],
|
Chris@87
|
6586 [0, 1, 2, 3, 4],
|
Chris@87
|
6587 [0, 1, 2, 3, 4],
|
Chris@87
|
6588 [0, 1, 2, 3, 4]]])
|
Chris@87
|
6589 >>> np.mgrid[-1:1:5j]
|
Chris@87
|
6590 array([-1. , -0.5, 0. , 0.5, 1. ])
|
Chris@87
|
6591
|
Chris@87
|
6592 """)
|
Chris@87
|
6593
|
Chris@87
|
6594 add_newdoc('numpy.lib.index_tricks', 'ogrid',
|
Chris@87
|
6595 """
|
Chris@87
|
6596 `nd_grid` instance which returns an open multi-dimensional "meshgrid".
|
Chris@87
|
6597
|
Chris@87
|
6598 An instance of `numpy.lib.index_tricks.nd_grid` which returns an open
|
Chris@87
|
6599 (i.e. not fleshed out) mesh-grid when indexed, so that only one dimension
|
Chris@87
|
6600 of each returned array is greater than 1. The dimension and number of the
|
Chris@87
|
6601 output arrays are equal to the number of indexing dimensions. If the step
|
Chris@87
|
6602 length is not a complex number, then the stop is not inclusive.
|
Chris@87
|
6603
|
Chris@87
|
6604 However, if the step length is a **complex number** (e.g. 5j), then
|
Chris@87
|
6605 the integer part of its magnitude is interpreted as specifying the
|
Chris@87
|
6606 number of points to create between the start and stop values, where
|
Chris@87
|
6607 the stop value **is inclusive**.
|
Chris@87
|
6608
|
Chris@87
|
6609 Returns
|
Chris@87
|
6610 ----------
|
Chris@87
|
6611 mesh-grid `ndarrays` with only one dimension :math:`\\neq 1`
|
Chris@87
|
6612
|
Chris@87
|
6613 See Also
|
Chris@87
|
6614 --------
|
Chris@87
|
6615 np.lib.index_tricks.nd_grid : class of `ogrid` and `mgrid` objects
|
Chris@87
|
6616 mgrid : like `ogrid` but returns dense (or fleshed out) mesh grids
|
Chris@87
|
6617 r_ : array concatenator
|
Chris@87
|
6618
|
Chris@87
|
6619 Examples
|
Chris@87
|
6620 --------
|
Chris@87
|
6621 >>> from numpy import ogrid
|
Chris@87
|
6622 >>> ogrid[-1:1:5j]
|
Chris@87
|
6623 array([-1. , -0.5, 0. , 0.5, 1. ])
|
Chris@87
|
6624 >>> ogrid[0:5,0:5]
|
Chris@87
|
6625 [array([[0],
|
Chris@87
|
6626 [1],
|
Chris@87
|
6627 [2],
|
Chris@87
|
6628 [3],
|
Chris@87
|
6629 [4]]), array([[0, 1, 2, 3, 4]])]
|
Chris@87
|
6630
|
Chris@87
|
6631 """)
|
Chris@87
|
6632
|
Chris@87
|
6633
|
Chris@87
|
6634 ##############################################################################
|
Chris@87
|
6635 #
|
Chris@87
|
6636 # Documentation for `generic` attributes and methods
|
Chris@87
|
6637 #
|
Chris@87
|
6638 ##############################################################################
|
Chris@87
|
6639
|
Chris@87
|
6640 add_newdoc('numpy.core.numerictypes', 'generic',
|
Chris@87
|
6641 """
|
Chris@87
|
6642 Base class for numpy scalar types.
|
Chris@87
|
6643
|
Chris@87
|
6644 Class from which most (all?) numpy scalar types are derived. For
|
Chris@87
|
6645 consistency, exposes the same API as `ndarray`, despite many
|
Chris@87
|
6646 consequent attributes being either "get-only," or completely irrelevant.
|
Chris@87
|
6647 This is the class from which it is strongly suggested users should derive
|
Chris@87
|
6648 custom scalar types.
|
Chris@87
|
6649
|
Chris@87
|
6650 """)
|
Chris@87
|
6651
|
Chris@87
|
6652 # Attributes
|
Chris@87
|
6653
|
Chris@87
|
6654 add_newdoc('numpy.core.numerictypes', 'generic', ('T',
|
Chris@87
|
6655 """
|
Chris@87
|
6656 Not implemented (virtual attribute)
|
Chris@87
|
6657
|
Chris@87
|
6658 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6659 albeit unimplemented, all the attributes of the ndarray class so as to
|
Chris@87
|
6660 provide a uniform API.
|
Chris@87
|
6661
|
Chris@87
|
6662 See Also
|
Chris@87
|
6663 --------
|
Chris@87
|
6664 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6665
|
Chris@87
|
6666 """))
|
Chris@87
|
6667
|
Chris@87
|
6668 add_newdoc('numpy.core.numerictypes', 'generic', ('base',
|
Chris@87
|
6669 """
|
Chris@87
|
6670 Not implemented (virtual attribute)
|
Chris@87
|
6671
|
Chris@87
|
6672 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6673 albeit unimplemented, all the attributes of the ndarray class so as to
|
Chris@87
|
6674 a uniform API.
|
Chris@87
|
6675
|
Chris@87
|
6676 See Also
|
Chris@87
|
6677 --------
|
Chris@87
|
6678 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6679
|
Chris@87
|
6680 """))
|
Chris@87
|
6681
|
Chris@87
|
6682 add_newdoc('numpy.core.numerictypes', 'generic', ('data',
|
Chris@87
|
6683 """Pointer to start of data."""))
|
Chris@87
|
6684
|
Chris@87
|
6685 add_newdoc('numpy.core.numerictypes', 'generic', ('dtype',
|
Chris@87
|
6686 """Get array data-descriptor."""))
|
Chris@87
|
6687
|
Chris@87
|
6688 add_newdoc('numpy.core.numerictypes', 'generic', ('flags',
|
Chris@87
|
6689 """The integer value of flags."""))
|
Chris@87
|
6690
|
Chris@87
|
6691 add_newdoc('numpy.core.numerictypes', 'generic', ('flat',
|
Chris@87
|
6692 """A 1-D view of the scalar."""))
|
Chris@87
|
6693
|
Chris@87
|
6694 add_newdoc('numpy.core.numerictypes', 'generic', ('imag',
|
Chris@87
|
6695 """The imaginary part of the scalar."""))
|
Chris@87
|
6696
|
Chris@87
|
6697 add_newdoc('numpy.core.numerictypes', 'generic', ('itemsize',
|
Chris@87
|
6698 """The length of one element in bytes."""))
|
Chris@87
|
6699
|
Chris@87
|
6700 add_newdoc('numpy.core.numerictypes', 'generic', ('nbytes',
|
Chris@87
|
6701 """The length of the scalar in bytes."""))
|
Chris@87
|
6702
|
Chris@87
|
6703 add_newdoc('numpy.core.numerictypes', 'generic', ('ndim',
|
Chris@87
|
6704 """The number of array dimensions."""))
|
Chris@87
|
6705
|
Chris@87
|
6706 add_newdoc('numpy.core.numerictypes', 'generic', ('real',
|
Chris@87
|
6707 """The real part of the scalar."""))
|
Chris@87
|
6708
|
Chris@87
|
6709 add_newdoc('numpy.core.numerictypes', 'generic', ('shape',
|
Chris@87
|
6710 """Tuple of array dimensions."""))
|
Chris@87
|
6711
|
Chris@87
|
6712 add_newdoc('numpy.core.numerictypes', 'generic', ('size',
|
Chris@87
|
6713 """The number of elements in the gentype."""))
|
Chris@87
|
6714
|
Chris@87
|
6715 add_newdoc('numpy.core.numerictypes', 'generic', ('strides',
|
Chris@87
|
6716 """Tuple of bytes steps in each dimension."""))
|
Chris@87
|
6717
|
Chris@87
|
6718 # Methods
|
Chris@87
|
6719
|
Chris@87
|
6720 add_newdoc('numpy.core.numerictypes', 'generic', ('all',
|
Chris@87
|
6721 """
|
Chris@87
|
6722 Not implemented (virtual attribute)
|
Chris@87
|
6723
|
Chris@87
|
6724 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6725 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6726 so as to provide a uniform API.
|
Chris@87
|
6727
|
Chris@87
|
6728 See Also
|
Chris@87
|
6729 --------
|
Chris@87
|
6730 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6731
|
Chris@87
|
6732 """))
|
Chris@87
|
6733
|
Chris@87
|
6734 add_newdoc('numpy.core.numerictypes', 'generic', ('any',
|
Chris@87
|
6735 """
|
Chris@87
|
6736 Not implemented (virtual attribute)
|
Chris@87
|
6737
|
Chris@87
|
6738 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6739 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6740 so as to provide a uniform API.
|
Chris@87
|
6741
|
Chris@87
|
6742 See Also
|
Chris@87
|
6743 --------
|
Chris@87
|
6744 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6745
|
Chris@87
|
6746 """))
|
Chris@87
|
6747
|
Chris@87
|
6748 add_newdoc('numpy.core.numerictypes', 'generic', ('argmax',
|
Chris@87
|
6749 """
|
Chris@87
|
6750 Not implemented (virtual attribute)
|
Chris@87
|
6751
|
Chris@87
|
6752 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6753 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6754 so as to provide a uniform API.
|
Chris@87
|
6755
|
Chris@87
|
6756 See Also
|
Chris@87
|
6757 --------
|
Chris@87
|
6758 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6759
|
Chris@87
|
6760 """))
|
Chris@87
|
6761
|
Chris@87
|
6762 add_newdoc('numpy.core.numerictypes', 'generic', ('argmin',
|
Chris@87
|
6763 """
|
Chris@87
|
6764 Not implemented (virtual attribute)
|
Chris@87
|
6765
|
Chris@87
|
6766 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6767 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6768 so as to provide a uniform API.
|
Chris@87
|
6769
|
Chris@87
|
6770 See Also
|
Chris@87
|
6771 --------
|
Chris@87
|
6772 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6773
|
Chris@87
|
6774 """))
|
Chris@87
|
6775
|
Chris@87
|
6776 add_newdoc('numpy.core.numerictypes', 'generic', ('argsort',
|
Chris@87
|
6777 """
|
Chris@87
|
6778 Not implemented (virtual attribute)
|
Chris@87
|
6779
|
Chris@87
|
6780 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6781 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6782 so as to provide a uniform API.
|
Chris@87
|
6783
|
Chris@87
|
6784 See Also
|
Chris@87
|
6785 --------
|
Chris@87
|
6786 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6787
|
Chris@87
|
6788 """))
|
Chris@87
|
6789
|
Chris@87
|
6790 add_newdoc('numpy.core.numerictypes', 'generic', ('astype',
|
Chris@87
|
6791 """
|
Chris@87
|
6792 Not implemented (virtual attribute)
|
Chris@87
|
6793
|
Chris@87
|
6794 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6795 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6796 so as to provide a uniform API.
|
Chris@87
|
6797
|
Chris@87
|
6798 See Also
|
Chris@87
|
6799 --------
|
Chris@87
|
6800 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6801
|
Chris@87
|
6802 """))
|
Chris@87
|
6803
|
Chris@87
|
6804 add_newdoc('numpy.core.numerictypes', 'generic', ('byteswap',
|
Chris@87
|
6805 """
|
Chris@87
|
6806 Not implemented (virtual attribute)
|
Chris@87
|
6807
|
Chris@87
|
6808 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6809 albeit unimplemented, all the attributes of the ndarray class so as to
|
Chris@87
|
6810 provide a uniform API.
|
Chris@87
|
6811
|
Chris@87
|
6812 See Also
|
Chris@87
|
6813 --------
|
Chris@87
|
6814 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6815
|
Chris@87
|
6816 """))
|
Chris@87
|
6817
|
Chris@87
|
6818 add_newdoc('numpy.core.numerictypes', 'generic', ('choose',
|
Chris@87
|
6819 """
|
Chris@87
|
6820 Not implemented (virtual attribute)
|
Chris@87
|
6821
|
Chris@87
|
6822 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6823 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6824 so as to provide a uniform API.
|
Chris@87
|
6825
|
Chris@87
|
6826 See Also
|
Chris@87
|
6827 --------
|
Chris@87
|
6828 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6829
|
Chris@87
|
6830 """))
|
Chris@87
|
6831
|
Chris@87
|
6832 add_newdoc('numpy.core.numerictypes', 'generic', ('clip',
|
Chris@87
|
6833 """
|
Chris@87
|
6834 Not implemented (virtual attribute)
|
Chris@87
|
6835
|
Chris@87
|
6836 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6837 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6838 so as to provide a uniform API.
|
Chris@87
|
6839
|
Chris@87
|
6840 See Also
|
Chris@87
|
6841 --------
|
Chris@87
|
6842 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6843
|
Chris@87
|
6844 """))
|
Chris@87
|
6845
|
Chris@87
|
6846 add_newdoc('numpy.core.numerictypes', 'generic', ('compress',
|
Chris@87
|
6847 """
|
Chris@87
|
6848 Not implemented (virtual attribute)
|
Chris@87
|
6849
|
Chris@87
|
6850 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6851 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6852 so as to provide a uniform API.
|
Chris@87
|
6853
|
Chris@87
|
6854 See Also
|
Chris@87
|
6855 --------
|
Chris@87
|
6856 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6857
|
Chris@87
|
6858 """))
|
Chris@87
|
6859
|
Chris@87
|
6860 add_newdoc('numpy.core.numerictypes', 'generic', ('conjugate',
|
Chris@87
|
6861 """
|
Chris@87
|
6862 Not implemented (virtual attribute)
|
Chris@87
|
6863
|
Chris@87
|
6864 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6865 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6866 so as to provide a uniform API.
|
Chris@87
|
6867
|
Chris@87
|
6868 See Also
|
Chris@87
|
6869 --------
|
Chris@87
|
6870 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6871
|
Chris@87
|
6872 """))
|
Chris@87
|
6873
|
Chris@87
|
6874 add_newdoc('numpy.core.numerictypes', 'generic', ('copy',
|
Chris@87
|
6875 """
|
Chris@87
|
6876 Not implemented (virtual attribute)
|
Chris@87
|
6877
|
Chris@87
|
6878 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6879 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6880 so as to provide a uniform API.
|
Chris@87
|
6881
|
Chris@87
|
6882 See Also
|
Chris@87
|
6883 --------
|
Chris@87
|
6884 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6885
|
Chris@87
|
6886 """))
|
Chris@87
|
6887
|
Chris@87
|
6888 add_newdoc('numpy.core.numerictypes', 'generic', ('cumprod',
|
Chris@87
|
6889 """
|
Chris@87
|
6890 Not implemented (virtual attribute)
|
Chris@87
|
6891
|
Chris@87
|
6892 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6893 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6894 so as to provide a uniform API.
|
Chris@87
|
6895
|
Chris@87
|
6896 See Also
|
Chris@87
|
6897 --------
|
Chris@87
|
6898 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6899
|
Chris@87
|
6900 """))
|
Chris@87
|
6901
|
Chris@87
|
6902 add_newdoc('numpy.core.numerictypes', 'generic', ('cumsum',
|
Chris@87
|
6903 """
|
Chris@87
|
6904 Not implemented (virtual attribute)
|
Chris@87
|
6905
|
Chris@87
|
6906 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6907 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6908 so as to provide a uniform API.
|
Chris@87
|
6909
|
Chris@87
|
6910 See Also
|
Chris@87
|
6911 --------
|
Chris@87
|
6912 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6913
|
Chris@87
|
6914 """))
|
Chris@87
|
6915
|
Chris@87
|
6916 add_newdoc('numpy.core.numerictypes', 'generic', ('diagonal',
|
Chris@87
|
6917 """
|
Chris@87
|
6918 Not implemented (virtual attribute)
|
Chris@87
|
6919
|
Chris@87
|
6920 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6921 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6922 so as to provide a uniform API.
|
Chris@87
|
6923
|
Chris@87
|
6924 See Also
|
Chris@87
|
6925 --------
|
Chris@87
|
6926 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6927
|
Chris@87
|
6928 """))
|
Chris@87
|
6929
|
Chris@87
|
6930 add_newdoc('numpy.core.numerictypes', 'generic', ('dump',
|
Chris@87
|
6931 """
|
Chris@87
|
6932 Not implemented (virtual attribute)
|
Chris@87
|
6933
|
Chris@87
|
6934 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6935 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6936 so as to provide a uniform API.
|
Chris@87
|
6937
|
Chris@87
|
6938 See Also
|
Chris@87
|
6939 --------
|
Chris@87
|
6940 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6941
|
Chris@87
|
6942 """))
|
Chris@87
|
6943
|
Chris@87
|
6944 add_newdoc('numpy.core.numerictypes', 'generic', ('dumps',
|
Chris@87
|
6945 """
|
Chris@87
|
6946 Not implemented (virtual attribute)
|
Chris@87
|
6947
|
Chris@87
|
6948 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6949 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6950 so as to provide a uniform API.
|
Chris@87
|
6951
|
Chris@87
|
6952 See Also
|
Chris@87
|
6953 --------
|
Chris@87
|
6954 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6955
|
Chris@87
|
6956 """))
|
Chris@87
|
6957
|
Chris@87
|
6958 add_newdoc('numpy.core.numerictypes', 'generic', ('fill',
|
Chris@87
|
6959 """
|
Chris@87
|
6960 Not implemented (virtual attribute)
|
Chris@87
|
6961
|
Chris@87
|
6962 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6963 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6964 so as to provide a uniform API.
|
Chris@87
|
6965
|
Chris@87
|
6966 See Also
|
Chris@87
|
6967 --------
|
Chris@87
|
6968 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6969
|
Chris@87
|
6970 """))
|
Chris@87
|
6971
|
Chris@87
|
6972 add_newdoc('numpy.core.numerictypes', 'generic', ('flatten',
|
Chris@87
|
6973 """
|
Chris@87
|
6974 Not implemented (virtual attribute)
|
Chris@87
|
6975
|
Chris@87
|
6976 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6977 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6978 so as to provide a uniform API.
|
Chris@87
|
6979
|
Chris@87
|
6980 See Also
|
Chris@87
|
6981 --------
|
Chris@87
|
6982 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6983
|
Chris@87
|
6984 """))
|
Chris@87
|
6985
|
Chris@87
|
6986 add_newdoc('numpy.core.numerictypes', 'generic', ('getfield',
|
Chris@87
|
6987 """
|
Chris@87
|
6988 Not implemented (virtual attribute)
|
Chris@87
|
6989
|
Chris@87
|
6990 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
6991 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
6992 so as to provide a uniform API.
|
Chris@87
|
6993
|
Chris@87
|
6994 See Also
|
Chris@87
|
6995 --------
|
Chris@87
|
6996 The corresponding attribute of the derived class of interest.
|
Chris@87
|
6997
|
Chris@87
|
6998 """))
|
Chris@87
|
6999
|
Chris@87
|
7000 add_newdoc('numpy.core.numerictypes', 'generic', ('item',
|
Chris@87
|
7001 """
|
Chris@87
|
7002 Not implemented (virtual attribute)
|
Chris@87
|
7003
|
Chris@87
|
7004 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7005 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7006 so as to provide a uniform API.
|
Chris@87
|
7007
|
Chris@87
|
7008 See Also
|
Chris@87
|
7009 --------
|
Chris@87
|
7010 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7011
|
Chris@87
|
7012 """))
|
Chris@87
|
7013
|
Chris@87
|
7014 add_newdoc('numpy.core.numerictypes', 'generic', ('itemset',
|
Chris@87
|
7015 """
|
Chris@87
|
7016 Not implemented (virtual attribute)
|
Chris@87
|
7017
|
Chris@87
|
7018 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7019 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7020 so as to provide a uniform API.
|
Chris@87
|
7021
|
Chris@87
|
7022 See Also
|
Chris@87
|
7023 --------
|
Chris@87
|
7024 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7025
|
Chris@87
|
7026 """))
|
Chris@87
|
7027
|
Chris@87
|
7028 add_newdoc('numpy.core.numerictypes', 'generic', ('max',
|
Chris@87
|
7029 """
|
Chris@87
|
7030 Not implemented (virtual attribute)
|
Chris@87
|
7031
|
Chris@87
|
7032 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7033 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7034 so as to provide a uniform API.
|
Chris@87
|
7035
|
Chris@87
|
7036 See Also
|
Chris@87
|
7037 --------
|
Chris@87
|
7038 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7039
|
Chris@87
|
7040 """))
|
Chris@87
|
7041
|
Chris@87
|
7042 add_newdoc('numpy.core.numerictypes', 'generic', ('mean',
|
Chris@87
|
7043 """
|
Chris@87
|
7044 Not implemented (virtual attribute)
|
Chris@87
|
7045
|
Chris@87
|
7046 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7047 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7048 so as to provide a uniform API.
|
Chris@87
|
7049
|
Chris@87
|
7050 See Also
|
Chris@87
|
7051 --------
|
Chris@87
|
7052 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7053
|
Chris@87
|
7054 """))
|
Chris@87
|
7055
|
Chris@87
|
7056 add_newdoc('numpy.core.numerictypes', 'generic', ('min',
|
Chris@87
|
7057 """
|
Chris@87
|
7058 Not implemented (virtual attribute)
|
Chris@87
|
7059
|
Chris@87
|
7060 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7061 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7062 so as to provide a uniform API.
|
Chris@87
|
7063
|
Chris@87
|
7064 See Also
|
Chris@87
|
7065 --------
|
Chris@87
|
7066 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7067
|
Chris@87
|
7068 """))
|
Chris@87
|
7069
|
Chris@87
|
7070 add_newdoc('numpy.core.numerictypes', 'generic', ('newbyteorder',
|
Chris@87
|
7071 """
|
Chris@87
|
7072 newbyteorder(new_order='S')
|
Chris@87
|
7073
|
Chris@87
|
7074 Return a new `dtype` with a different byte order.
|
Chris@87
|
7075
|
Chris@87
|
7076 Changes are also made in all fields and sub-arrays of the data type.
|
Chris@87
|
7077
|
Chris@87
|
7078 The `new_order` code can be any from the following:
|
Chris@87
|
7079
|
Chris@87
|
7080 * {'<', 'L'} - little endian
|
Chris@87
|
7081 * {'>', 'B'} - big endian
|
Chris@87
|
7082 * {'=', 'N'} - native order
|
Chris@87
|
7083 * 'S' - swap dtype from current to opposite endian
|
Chris@87
|
7084 * {'|', 'I'} - ignore (no change to byte order)
|
Chris@87
|
7085
|
Chris@87
|
7086 Parameters
|
Chris@87
|
7087 ----------
|
Chris@87
|
7088 new_order : str, optional
|
Chris@87
|
7089 Byte order to force; a value from the byte order specifications
|
Chris@87
|
7090 above. The default value ('S') results in swapping the current
|
Chris@87
|
7091 byte order. The code does a case-insensitive check on the first
|
Chris@87
|
7092 letter of `new_order` for the alternatives above. For example,
|
Chris@87
|
7093 any of 'B' or 'b' or 'biggish' are valid to specify big-endian.
|
Chris@87
|
7094
|
Chris@87
|
7095
|
Chris@87
|
7096 Returns
|
Chris@87
|
7097 -------
|
Chris@87
|
7098 new_dtype : dtype
|
Chris@87
|
7099 New `dtype` object with the given change to the byte order.
|
Chris@87
|
7100
|
Chris@87
|
7101 """))
|
Chris@87
|
7102
|
Chris@87
|
7103 add_newdoc('numpy.core.numerictypes', 'generic', ('nonzero',
|
Chris@87
|
7104 """
|
Chris@87
|
7105 Not implemented (virtual attribute)
|
Chris@87
|
7106
|
Chris@87
|
7107 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7108 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7109 so as to provide a uniform API.
|
Chris@87
|
7110
|
Chris@87
|
7111 See Also
|
Chris@87
|
7112 --------
|
Chris@87
|
7113 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7114
|
Chris@87
|
7115 """))
|
Chris@87
|
7116
|
Chris@87
|
7117 add_newdoc('numpy.core.numerictypes', 'generic', ('prod',
|
Chris@87
|
7118 """
|
Chris@87
|
7119 Not implemented (virtual attribute)
|
Chris@87
|
7120
|
Chris@87
|
7121 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7122 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7123 so as to provide a uniform API.
|
Chris@87
|
7124
|
Chris@87
|
7125 See Also
|
Chris@87
|
7126 --------
|
Chris@87
|
7127 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7128
|
Chris@87
|
7129 """))
|
Chris@87
|
7130
|
Chris@87
|
7131 add_newdoc('numpy.core.numerictypes', 'generic', ('ptp',
|
Chris@87
|
7132 """
|
Chris@87
|
7133 Not implemented (virtual attribute)
|
Chris@87
|
7134
|
Chris@87
|
7135 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7136 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7137 so as to provide a uniform API.
|
Chris@87
|
7138
|
Chris@87
|
7139 See Also
|
Chris@87
|
7140 --------
|
Chris@87
|
7141 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7142
|
Chris@87
|
7143 """))
|
Chris@87
|
7144
|
Chris@87
|
7145 add_newdoc('numpy.core.numerictypes', 'generic', ('put',
|
Chris@87
|
7146 """
|
Chris@87
|
7147 Not implemented (virtual attribute)
|
Chris@87
|
7148
|
Chris@87
|
7149 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7150 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7151 so as to provide a uniform API.
|
Chris@87
|
7152
|
Chris@87
|
7153 See Also
|
Chris@87
|
7154 --------
|
Chris@87
|
7155 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7156
|
Chris@87
|
7157 """))
|
Chris@87
|
7158
|
Chris@87
|
7159 add_newdoc('numpy.core.numerictypes', 'generic', ('ravel',
|
Chris@87
|
7160 """
|
Chris@87
|
7161 Not implemented (virtual attribute)
|
Chris@87
|
7162
|
Chris@87
|
7163 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7164 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7165 so as to provide a uniform API.
|
Chris@87
|
7166
|
Chris@87
|
7167 See Also
|
Chris@87
|
7168 --------
|
Chris@87
|
7169 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7170
|
Chris@87
|
7171 """))
|
Chris@87
|
7172
|
Chris@87
|
7173 add_newdoc('numpy.core.numerictypes', 'generic', ('repeat',
|
Chris@87
|
7174 """
|
Chris@87
|
7175 Not implemented (virtual attribute)
|
Chris@87
|
7176
|
Chris@87
|
7177 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7178 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7179 so as to provide a uniform API.
|
Chris@87
|
7180
|
Chris@87
|
7181 See Also
|
Chris@87
|
7182 --------
|
Chris@87
|
7183 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7184
|
Chris@87
|
7185 """))
|
Chris@87
|
7186
|
Chris@87
|
7187 add_newdoc('numpy.core.numerictypes', 'generic', ('reshape',
|
Chris@87
|
7188 """
|
Chris@87
|
7189 Not implemented (virtual attribute)
|
Chris@87
|
7190
|
Chris@87
|
7191 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7192 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7193 so as to provide a uniform API.
|
Chris@87
|
7194
|
Chris@87
|
7195 See Also
|
Chris@87
|
7196 --------
|
Chris@87
|
7197 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7198
|
Chris@87
|
7199 """))
|
Chris@87
|
7200
|
Chris@87
|
7201 add_newdoc('numpy.core.numerictypes', 'generic', ('resize',
|
Chris@87
|
7202 """
|
Chris@87
|
7203 Not implemented (virtual attribute)
|
Chris@87
|
7204
|
Chris@87
|
7205 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7206 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7207 so as to provide a uniform API.
|
Chris@87
|
7208
|
Chris@87
|
7209 See Also
|
Chris@87
|
7210 --------
|
Chris@87
|
7211 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7212
|
Chris@87
|
7213 """))
|
Chris@87
|
7214
|
Chris@87
|
7215 add_newdoc('numpy.core.numerictypes', 'generic', ('round',
|
Chris@87
|
7216 """
|
Chris@87
|
7217 Not implemented (virtual attribute)
|
Chris@87
|
7218
|
Chris@87
|
7219 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7220 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7221 so as to provide a uniform API.
|
Chris@87
|
7222
|
Chris@87
|
7223 See Also
|
Chris@87
|
7224 --------
|
Chris@87
|
7225 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7226
|
Chris@87
|
7227 """))
|
Chris@87
|
7228
|
Chris@87
|
7229 add_newdoc('numpy.core.numerictypes', 'generic', ('searchsorted',
|
Chris@87
|
7230 """
|
Chris@87
|
7231 Not implemented (virtual attribute)
|
Chris@87
|
7232
|
Chris@87
|
7233 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7234 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7235 so as to provide a uniform API.
|
Chris@87
|
7236
|
Chris@87
|
7237 See Also
|
Chris@87
|
7238 --------
|
Chris@87
|
7239 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7240
|
Chris@87
|
7241 """))
|
Chris@87
|
7242
|
Chris@87
|
7243 add_newdoc('numpy.core.numerictypes', 'generic', ('setfield',
|
Chris@87
|
7244 """
|
Chris@87
|
7245 Not implemented (virtual attribute)
|
Chris@87
|
7246
|
Chris@87
|
7247 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7248 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7249 so as to provide a uniform API.
|
Chris@87
|
7250
|
Chris@87
|
7251 See Also
|
Chris@87
|
7252 --------
|
Chris@87
|
7253 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7254
|
Chris@87
|
7255 """))
|
Chris@87
|
7256
|
Chris@87
|
7257 add_newdoc('numpy.core.numerictypes', 'generic', ('setflags',
|
Chris@87
|
7258 """
|
Chris@87
|
7259 Not implemented (virtual attribute)
|
Chris@87
|
7260
|
Chris@87
|
7261 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7262 albeit unimplemented, all the attributes of the ndarray class so as to
|
Chris@87
|
7263 provide a uniform API.
|
Chris@87
|
7264
|
Chris@87
|
7265 See Also
|
Chris@87
|
7266 --------
|
Chris@87
|
7267 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7268
|
Chris@87
|
7269 """))
|
Chris@87
|
7270
|
Chris@87
|
7271 add_newdoc('numpy.core.numerictypes', 'generic', ('sort',
|
Chris@87
|
7272 """
|
Chris@87
|
7273 Not implemented (virtual attribute)
|
Chris@87
|
7274
|
Chris@87
|
7275 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7276 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7277 so as to provide a uniform API.
|
Chris@87
|
7278
|
Chris@87
|
7279 See Also
|
Chris@87
|
7280 --------
|
Chris@87
|
7281 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7282
|
Chris@87
|
7283 """))
|
Chris@87
|
7284
|
Chris@87
|
7285 add_newdoc('numpy.core.numerictypes', 'generic', ('squeeze',
|
Chris@87
|
7286 """
|
Chris@87
|
7287 Not implemented (virtual attribute)
|
Chris@87
|
7288
|
Chris@87
|
7289 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7290 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7291 so as to provide a uniform API.
|
Chris@87
|
7292
|
Chris@87
|
7293 See Also
|
Chris@87
|
7294 --------
|
Chris@87
|
7295 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7296
|
Chris@87
|
7297 """))
|
Chris@87
|
7298
|
Chris@87
|
7299 add_newdoc('numpy.core.numerictypes', 'generic', ('std',
|
Chris@87
|
7300 """
|
Chris@87
|
7301 Not implemented (virtual attribute)
|
Chris@87
|
7302
|
Chris@87
|
7303 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7304 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7305 so as to provide a uniform API.
|
Chris@87
|
7306
|
Chris@87
|
7307 See Also
|
Chris@87
|
7308 --------
|
Chris@87
|
7309 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7310
|
Chris@87
|
7311 """))
|
Chris@87
|
7312
|
Chris@87
|
7313 add_newdoc('numpy.core.numerictypes', 'generic', ('sum',
|
Chris@87
|
7314 """
|
Chris@87
|
7315 Not implemented (virtual attribute)
|
Chris@87
|
7316
|
Chris@87
|
7317 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7318 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7319 so as to provide a uniform API.
|
Chris@87
|
7320
|
Chris@87
|
7321 See Also
|
Chris@87
|
7322 --------
|
Chris@87
|
7323 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7324
|
Chris@87
|
7325 """))
|
Chris@87
|
7326
|
Chris@87
|
7327 add_newdoc('numpy.core.numerictypes', 'generic', ('swapaxes',
|
Chris@87
|
7328 """
|
Chris@87
|
7329 Not implemented (virtual attribute)
|
Chris@87
|
7330
|
Chris@87
|
7331 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7332 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7333 so as to provide a uniform API.
|
Chris@87
|
7334
|
Chris@87
|
7335 See Also
|
Chris@87
|
7336 --------
|
Chris@87
|
7337 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7338
|
Chris@87
|
7339 """))
|
Chris@87
|
7340
|
Chris@87
|
7341 add_newdoc('numpy.core.numerictypes', 'generic', ('take',
|
Chris@87
|
7342 """
|
Chris@87
|
7343 Not implemented (virtual attribute)
|
Chris@87
|
7344
|
Chris@87
|
7345 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7346 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7347 so as to provide a uniform API.
|
Chris@87
|
7348
|
Chris@87
|
7349 See Also
|
Chris@87
|
7350 --------
|
Chris@87
|
7351 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7352
|
Chris@87
|
7353 """))
|
Chris@87
|
7354
|
Chris@87
|
7355 add_newdoc('numpy.core.numerictypes', 'generic', ('tofile',
|
Chris@87
|
7356 """
|
Chris@87
|
7357 Not implemented (virtual attribute)
|
Chris@87
|
7358
|
Chris@87
|
7359 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7360 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7361 so as to provide a uniform API.
|
Chris@87
|
7362
|
Chris@87
|
7363 See Also
|
Chris@87
|
7364 --------
|
Chris@87
|
7365 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7366
|
Chris@87
|
7367 """))
|
Chris@87
|
7368
|
Chris@87
|
7369 add_newdoc('numpy.core.numerictypes', 'generic', ('tolist',
|
Chris@87
|
7370 """
|
Chris@87
|
7371 Not implemented (virtual attribute)
|
Chris@87
|
7372
|
Chris@87
|
7373 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7374 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7375 so as to provide a uniform API.
|
Chris@87
|
7376
|
Chris@87
|
7377 See Also
|
Chris@87
|
7378 --------
|
Chris@87
|
7379 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7380
|
Chris@87
|
7381 """))
|
Chris@87
|
7382
|
Chris@87
|
7383 add_newdoc('numpy.core.numerictypes', 'generic', ('tostring',
|
Chris@87
|
7384 """
|
Chris@87
|
7385 Not implemented (virtual attribute)
|
Chris@87
|
7386
|
Chris@87
|
7387 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7388 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7389 so as to provide a uniform API.
|
Chris@87
|
7390
|
Chris@87
|
7391 See Also
|
Chris@87
|
7392 --------
|
Chris@87
|
7393 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7394
|
Chris@87
|
7395 """))
|
Chris@87
|
7396
|
Chris@87
|
7397 add_newdoc('numpy.core.numerictypes', 'generic', ('trace',
|
Chris@87
|
7398 """
|
Chris@87
|
7399 Not implemented (virtual attribute)
|
Chris@87
|
7400
|
Chris@87
|
7401 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7402 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7403 so as to provide a uniform API.
|
Chris@87
|
7404
|
Chris@87
|
7405 See Also
|
Chris@87
|
7406 --------
|
Chris@87
|
7407 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7408
|
Chris@87
|
7409 """))
|
Chris@87
|
7410
|
Chris@87
|
7411 add_newdoc('numpy.core.numerictypes', 'generic', ('transpose',
|
Chris@87
|
7412 """
|
Chris@87
|
7413 Not implemented (virtual attribute)
|
Chris@87
|
7414
|
Chris@87
|
7415 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7416 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7417 so as to provide a uniform API.
|
Chris@87
|
7418
|
Chris@87
|
7419 See Also
|
Chris@87
|
7420 --------
|
Chris@87
|
7421 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7422
|
Chris@87
|
7423 """))
|
Chris@87
|
7424
|
Chris@87
|
7425 add_newdoc('numpy.core.numerictypes', 'generic', ('var',
|
Chris@87
|
7426 """
|
Chris@87
|
7427 Not implemented (virtual attribute)
|
Chris@87
|
7428
|
Chris@87
|
7429 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7430 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7431 so as to provide a uniform API.
|
Chris@87
|
7432
|
Chris@87
|
7433 See Also
|
Chris@87
|
7434 --------
|
Chris@87
|
7435 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7436
|
Chris@87
|
7437 """))
|
Chris@87
|
7438
|
Chris@87
|
7439 add_newdoc('numpy.core.numerictypes', 'generic', ('view',
|
Chris@87
|
7440 """
|
Chris@87
|
7441 Not implemented (virtual attribute)
|
Chris@87
|
7442
|
Chris@87
|
7443 Class generic exists solely to derive numpy scalars from, and possesses,
|
Chris@87
|
7444 albeit unimplemented, all the attributes of the ndarray class
|
Chris@87
|
7445 so as to provide a uniform API.
|
Chris@87
|
7446
|
Chris@87
|
7447 See Also
|
Chris@87
|
7448 --------
|
Chris@87
|
7449 The corresponding attribute of the derived class of interest.
|
Chris@87
|
7450
|
Chris@87
|
7451 """))
|
Chris@87
|
7452
|
Chris@87
|
7453
|
Chris@87
|
7454 ##############################################################################
|
Chris@87
|
7455 #
|
Chris@87
|
7456 # Documentation for other scalar classes
|
Chris@87
|
7457 #
|
Chris@87
|
7458 ##############################################################################
|
Chris@87
|
7459
|
Chris@87
|
7460 add_newdoc('numpy.core.numerictypes', 'bool_',
|
Chris@87
|
7461 """Numpy's Boolean type. Character code: ``?``. Alias: bool8""")
|
Chris@87
|
7462
|
Chris@87
|
7463 add_newdoc('numpy.core.numerictypes', 'complex64',
|
Chris@87
|
7464 """
|
Chris@87
|
7465 Complex number type composed of two 32 bit floats. Character code: 'F'.
|
Chris@87
|
7466
|
Chris@87
|
7467 """)
|
Chris@87
|
7468
|
Chris@87
|
7469 add_newdoc('numpy.core.numerictypes', 'complex128',
|
Chris@87
|
7470 """
|
Chris@87
|
7471 Complex number type composed of two 64 bit floats. Character code: 'D'.
|
Chris@87
|
7472 Python complex compatible.
|
Chris@87
|
7473
|
Chris@87
|
7474 """)
|
Chris@87
|
7475
|
Chris@87
|
7476 add_newdoc('numpy.core.numerictypes', 'complex256',
|
Chris@87
|
7477 """
|
Chris@87
|
7478 Complex number type composed of two 128-bit floats. Character code: 'G'.
|
Chris@87
|
7479
|
Chris@87
|
7480 """)
|
Chris@87
|
7481
|
Chris@87
|
7482 add_newdoc('numpy.core.numerictypes', 'float32',
|
Chris@87
|
7483 """
|
Chris@87
|
7484 32-bit floating-point number. Character code 'f'. C float compatible.
|
Chris@87
|
7485
|
Chris@87
|
7486 """)
|
Chris@87
|
7487
|
Chris@87
|
7488 add_newdoc('numpy.core.numerictypes', 'float64',
|
Chris@87
|
7489 """
|
Chris@87
|
7490 64-bit floating-point number. Character code 'd'. Python float compatible.
|
Chris@87
|
7491
|
Chris@87
|
7492 """)
|
Chris@87
|
7493
|
Chris@87
|
7494 add_newdoc('numpy.core.numerictypes', 'float96',
|
Chris@87
|
7495 """
|
Chris@87
|
7496 """)
|
Chris@87
|
7497
|
Chris@87
|
7498 add_newdoc('numpy.core.numerictypes', 'float128',
|
Chris@87
|
7499 """
|
Chris@87
|
7500 128-bit floating-point number. Character code: 'g'. C long float
|
Chris@87
|
7501 compatible.
|
Chris@87
|
7502
|
Chris@87
|
7503 """)
|
Chris@87
|
7504
|
Chris@87
|
7505 add_newdoc('numpy.core.numerictypes', 'int8',
|
Chris@87
|
7506 """8-bit integer. Character code ``b``. C char compatible.""")
|
Chris@87
|
7507
|
Chris@87
|
7508 add_newdoc('numpy.core.numerictypes', 'int16',
|
Chris@87
|
7509 """16-bit integer. Character code ``h``. C short compatible.""")
|
Chris@87
|
7510
|
Chris@87
|
7511 add_newdoc('numpy.core.numerictypes', 'int32',
|
Chris@87
|
7512 """32-bit integer. Character code 'i'. C int compatible.""")
|
Chris@87
|
7513
|
Chris@87
|
7514 add_newdoc('numpy.core.numerictypes', 'int64',
|
Chris@87
|
7515 """64-bit integer. Character code 'l'. Python int compatible.""")
|
Chris@87
|
7516
|
Chris@87
|
7517 add_newdoc('numpy.core.numerictypes', 'object_',
|
Chris@87
|
7518 """Any Python object. Character code: 'O'.""")
|