summaryrefslogtreecommitdiff
path: root/numpy/matrixlib/defmatrix.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-07-31 19:29:27 -0600
committerCharles Harris <charlesr.harris@gmail.com>2014-07-31 19:29:27 -0600
commit1e22553c37e9112bf2426c1b060275419f906d8d (patch)
treeac24a3255d0d6db162daca5f3df93f1b745601c1 /numpy/matrixlib/defmatrix.py
parentae7c942ced535fb39384aefeb8d32df92fb15988 (diff)
parent650d4ef1b16c48fe443c3781b27e0f942be3ceb5 (diff)
downloadnumpy-1e22553c37e9112bf2426c1b060275419f906d8d.tar.gz
Merge pull request #4931 from argriffing/matrix-docstrings
DOC: matrix flatten docstring
Diffstat (limited to 'numpy/matrixlib/defmatrix.py')
-rw-r--r--numpy/matrixlib/defmatrix.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py
index 0fd5db66a..1c7e29d53 100644
--- a/numpy/matrixlib/defmatrix.py
+++ b/numpy/matrixlib/defmatrix.py
@@ -454,6 +454,42 @@ class matrix(N.ndarray):
"""
return N.ndarray.sum(self, axis, dtype, out, keepdims=True)._collapse(axis)
+ # To update docstring from array to matrix...
+ def flatten(self, order='C'):
+ """
+ Return a flattened copy of the matrix.
+
+ All `N` elements of the matrix are placed into a single row.
+
+ Parameters
+ ----------
+ order : {'C', 'F', 'A'}, optional
+ Whether to flatten in C (row-major), Fortran (column-major) order,
+ or preserve the C/Fortran ordering from `m`.
+ The default is 'C'.
+
+ Returns
+ -------
+ y : matrix
+ A copy of the matrix, flattened to a `(1, N)` matrix where `N`
+ is the number of elements in the original matrix.
+
+ See Also
+ --------
+ ravel : Return a flattened array.
+ flat : A 1-D flat iterator over the matrix.
+
+ Examples
+ --------
+ >>> m = np.matrix([[1,2], [3,4]])
+ >>> m.flatten()
+ matrix([[1, 2, 3, 4]])
+ >>> m.flatten('F')
+ matrix([[1, 3, 2, 4]])
+
+ """
+ return N.ndarray.flatten(self, order=order)
+
def mean(self, axis=None, dtype=None, out=None):
"""
Returns the average of the matrix elements along the given axis.