Give a new shape to the array without changing its data. Returns a masked array containing the same data, but with a new shape. The result is a view on the original array; if this is not possible, a ValueError is raised. Parameters ----------
(self, *s, **kwargs)
| 4684 | |
| 4685 | |
| 4686 | def reshape(self, *s, **kwargs): |
| 4687 | """ |
| 4688 | Give a new shape to the array without changing its data. |
| 4689 | |
| 4690 | Returns a masked array containing the same data, but with a new shape. |
| 4691 | The result is a view on the original array; if this is not possible, a |
| 4692 | ValueError is raised. |
| 4693 | |
| 4694 | Parameters |
| 4695 | ---------- |
| 4696 | shape : int or tuple of ints |
| 4697 | The new shape should be compatible with the original shape. If an |
| 4698 | integer is supplied, then the result will be a 1-D array of that |
| 4699 | length. |
| 4700 | order : {'C', 'F'}, optional |
| 4701 | Determines whether the array data should be viewed as in C |
| 4702 | (row-major) or FORTRAN (column-major) order. |
| 4703 | |
| 4704 | Returns |
| 4705 | ------- |
| 4706 | reshaped_array : array |
| 4707 | A new view on the array. |
| 4708 | |
| 4709 | See Also |
| 4710 | -------- |
| 4711 | reshape : Equivalent function in the masked array module. |
| 4712 | numpy.ndarray.reshape : Equivalent method on ndarray object. |
| 4713 | numpy.reshape : Equivalent function in the NumPy module. |
| 4714 | |
| 4715 | Notes |
| 4716 | ----- |
| 4717 | The reshaping operation cannot guarantee that a copy will not be made, |
| 4718 | to modify the shape in place, use ``a.shape = s`` |
| 4719 | |
| 4720 | Examples |
| 4721 | -------- |
| 4722 | >>> x = np.ma.array([[1,2],[3,4]], mask=[1,0,0,1]) |
| 4723 | >>> x |
| 4724 | masked_array( |
| 4725 | data=[[--, 2], |
| 4726 | [3, --]], |
| 4727 | mask=[[ True, False], |
| 4728 | [False, True]], |
| 4729 | fill_value=999999) |
| 4730 | >>> x = x.reshape((4,1)) |
| 4731 | >>> x |
| 4732 | masked_array( |
| 4733 | data=[[--], |
| 4734 | [2], |
| 4735 | [3], |
| 4736 | [--]], |
| 4737 | mask=[[ True], |
| 4738 | [False], |
| 4739 | [False], |
| 4740 | [ True]], |
| 4741 | fill_value=999999) |
| 4742 | |
| 4743 | """ |