A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.scipy.org/doc/numpy/reference/generated/numpy.matrix.squeeze.html below:

numpy.matrix.squeeze — NumPy v2.3 Manual

numpy.matrix.squeeze#

method

matrix.squeeze(axis=None)[source]#

Return a possibly reshaped matrix.

Refer to numpy.squeeze for more documentation.

Parameters:
axisNone or int or tuple of ints, optional

Selects a subset of the axes of length one in the shape. If an axis is selected with shape entry greater than one, an error is raised.

Returns:
squeezedmatrix

The matrix, but as a (1, N) matrix if it had shape (N, 1).

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]])

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4