summaryrefslogtreecommitdiff
path: root/numpy/matrixlib/defmatrix.py
diff options
context:
space:
mode:
authoralex <argriffi@ncsu.edu>2014-08-01 23:41:36 -0400
committeralex <argriffi@ncsu.edu>2014-08-01 23:41:36 -0400
commit2aa2132e9e3b98dacfe6b7a0f9273d83c812852b (patch)
treeabf070880f10136f3f8a60a463bb83d072dc2fdf /numpy/matrixlib/defmatrix.py
parent1e22553c37e9112bf2426c1b060275419f906d8d (diff)
downloadnumpy-2aa2132e9e3b98dacfe6b7a0f9273d83c812852b.tar.gz
DOC: matrix.squeeze docstring
Diffstat (limited to 'numpy/matrixlib/defmatrix.py')
-rw-r--r--numpy/matrixlib/defmatrix.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py
index 1c7e29d53..c054f5432 100644
--- a/numpy/matrixlib/defmatrix.py
+++ b/numpy/matrixlib/defmatrix.py
@@ -454,6 +454,60 @@ class matrix(N.ndarray):
"""
return N.ndarray.sum(self, axis, dtype, out, keepdims=True)._collapse(axis)
+
+ # To update docstring from array to matrix...
+ def squeeze(self, axis=None):
+ """
+ Return a possibly reshaped matrix.
+
+ Refer to `numpy.squeeze` for more documentation.
+
+ Parameters
+ ----------
+ axis : None or int or tuple of ints, optional
+ Selects a subset of the single-dimensional entries in the shape.
+ If an axis is selected with shape entry greater than one,
+ an error is raised.
+
+ Returns
+ -------
+ squeezed : matrix
+ The matrix, but as a (1, N) matrix if it had shape (N, 1).
+
+ See Also
+ --------
+ numpy.squeeze : related function
+
+ Notes
+ -----
+ If `m` has a single column then that column is returned
+ as the single row of a matrix. Otherwise `m` is returned.
+ The returned matrix is always either `m` itself or a view into `m`.
+ Supplying an axis keyword argument will not affect the returned matrix
+ but it may cause an error to be raised.
+
+ Examples
+ --------
+ >>> c = np.matrix([[1], [2]])
+ >>> c
+ matrix([[1],
+ [2]])
+ >>> c.squeeze()
+ matrix([[1, 2]])
+ >>> r = c.T
+ >>> r
+ matrix([[1, 2]])
+ >>> r.squeeze()
+ matrix([[1, 2]])
+ >>> m = np.matrix([[1, 2], [3, 4]])
+ >>> m.squeeze()
+ matrix([[1, 2],
+ [3, 4]])
+
+ """
+ return N.ndarray.squeeze(self, axis=axis)
+
+
# To update docstring from array to matrix...
def flatten(self, order='C'):
"""