Permute the dimensions of an array. This function is exactly equivalent to `numpy.transpose`. See Also -------- numpy.transpose : Equivalent function in top-level NumPy module. Examples -------- >>> import numpy.ma as ma >>> x = ma.arange(4).reshape((2,2))
(a, axes=None)
| 7318 | |
| 7319 | |
| 7320 | def transpose(a, axes=None): |
| 7321 | """ |
| 7322 | Permute the dimensions of an array. |
| 7323 | |
| 7324 | This function is exactly equivalent to `numpy.transpose`. |
| 7325 | |
| 7326 | See Also |
| 7327 | -------- |
| 7328 | numpy.transpose : Equivalent function in top-level NumPy module. |
| 7329 | |
| 7330 | Examples |
| 7331 | -------- |
| 7332 | >>> import numpy.ma as ma |
| 7333 | >>> x = ma.arange(4).reshape((2,2)) |
| 7334 | >>> x[1, 1] = ma.masked |
| 7335 | >>> x |
| 7336 | masked_array( |
| 7337 | data=[[0, 1], |
| 7338 | [2, --]], |
| 7339 | mask=[[False, False], |
| 7340 | [False, True]], |
| 7341 | fill_value=999999) |
| 7342 | |
| 7343 | >>> ma.transpose(x) |
| 7344 | masked_array( |
| 7345 | data=[[0, 2], |
| 7346 | [1, --]], |
| 7347 | mask=[[False, False], |
| 7348 | [False, True]], |
| 7349 | fill_value=999999) |
| 7350 | """ |
| 7351 | # We can't use 'frommethod', as 'transpose' doesn't take keywords |
| 7352 | try: |
| 7353 | return a.transpose(axes) |
| 7354 | except AttributeError: |
| 7355 | return narray(a, copy=False).transpose(axes).view(MaskedArray) |
| 7356 | |
| 7357 | |
| 7358 | def reshape(a, new_shape, order='C'): |