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