MCPcopy Create free account
hub / github.com/numpy/numpy / flatten

Method flatten

numpy/matrixlib/defmatrix.py:377–412  ·  view source on GitHub ↗

Return a flattened copy of the matrix. All `N` elements of the matrix are placed into a single row. Parameters ---------- order : {'C', 'F', 'A', 'K'}, optional 'C' means to flatten in row-major (C-style) order. 'F' means to flatten

(self, order='C')

Source from the content-addressed store, hash-verified

375
376 # To update docstring from array to matrix...
377 def flatten(self, order='C'):
378 """
379 Return a flattened copy of the matrix.
380
381 All `N` elements of the matrix are placed into a single row.
382
383 Parameters
384 ----------
385 order : {'C', 'F', 'A', 'K'}, optional
386 'C' means to flatten in row-major (C-style) order. 'F' means to
387 flatten in column-major (Fortran-style) order. 'A' means to
388 flatten in column-major order if `m` is Fortran *contiguous* in
389 memory, row-major order otherwise. 'K' means to flatten `m` in
390 the order the elements occur in memory. The default is 'C'.
391
392 Returns
393 -------
394 y : matrix
395 A copy of the matrix, flattened to a `(1, N)` matrix where `N`
396 is the number of elements in the original matrix.
397
398 See Also
399 --------
400 ravel : Return a flattened array.
401 flat : A 1-D flat iterator over the matrix.
402
403 Examples
404 --------
405 >>> m = np.matrix([[1,2], [3,4]])
406 >>> m.flatten()
407 matrix([[1, 2, 3, 4]])
408 >>> m.flatten('F')
409 matrix([[1, 3, 2, 4]])
410
411 """
412 return N.ndarray.flatten(self, order=order)
413
414 def mean(self, axis=None, dtype=None, out=None):
415 """

Callers 15

test_member_flattenMethod · 0.80
partitionFunction · 0.80
sortFunction · 0.80
test_attributesMethod · 0.80
test_overflowsMethod · 0.80
test_flattenMethod · 0.80
_unique1dFunction · 0.80

Calls

no outgoing calls

Tested by 13

test_member_flattenMethod · 0.64
test_attributesMethod · 0.64
test_overflowsMethod · 0.64
test_flattenMethod · 0.64
test_extended_axisMethod · 0.64
test_extended_axisMethod · 0.64
_isin_slowMethod · 0.64