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)
| 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'): |
no outgoing calls