MCPcopy
hub / github.com/numpy/numpy / squeeze

Method squeeze

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

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 axes of length one in the shape. If an axis is selected w

(self, axis=None)

Source from the content-addressed store, hash-verified

326
327 # To update docstring from array to matrix...
328 def squeeze(self, axis=None):
329 """
330 Return a possibly reshaped matrix.
331
332 Refer to `numpy.squeeze` for more documentation.
333
334 Parameters
335 ----------
336 axis : None or int or tuple of ints, optional
337 Selects a subset of the axes of length one in the shape.
338 If an axis is selected with shape entry greater than one,
339 an error is raised.
340
341 Returns
342 -------
343 squeezed : matrix
344 The matrix, but as a (1, N) matrix if it had shape (N, 1).
345
346 See Also
347 --------
348 numpy.squeeze : related function
349
350 Notes
351 -----
352 If `m` has a single column then that column is returned
353 as the single row of a matrix. Otherwise `m` is returned.
354 The returned matrix is always either `m` itself or a view into `m`.
355 Supplying an axis keyword argument will not affect the returned matrix
356 but it may cause an error to be raised.
357
358 Examples
359 --------
360 >>> c = np.matrix([[1], [2]])
361 >>> c
362 matrix([[1],
363 [2]])
364 >>> c.squeeze()
365 matrix([[1, 2]])
366 >>> r = c.T
367 >>> r
368 matrix([[1, 2]])
369 >>> r.squeeze()
370 matrix([[1, 2]])
371 >>> m = np.matrix([[1, 2], [3, 4]])
372 >>> m.squeeze()
373 matrix([[1, 2],
374 [3, 4]])
375
376 """
377 return N.ndarray.squeeze(self, axis=axis)
378
379 # To update docstring from array to matrix...
380 def flatten(self, order='C'):

Callers 15

covFunction · 0.45
_ensure_ndmin_ndarrayFunction · 0.45
_get_linear_rampsFunction · 0.45
nanvarFunction · 0.45
sum_to_0dMethod · 0.45
test_functionalityMethod · 0.45
test_basicMethod · 0.45
test_simpleMethod · 0.45
lstsqFunction · 0.45
test_keepdimsMethod · 0.45
fromnumeric.pyFile · 0.45

Calls

no outgoing calls

Tested by 7

sum_to_0dMethod · 0.36
test_functionalityMethod · 0.36
test_basicMethod · 0.36
test_simpleMethod · 0.36
test_keepdimsMethod · 0.36
test_squeezeMethod · 0.36
test_view_to_typeMethod · 0.36