Returns a reshaped masked 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)
| 4750 | return r |
| 4751 | |
| 4752 | def reshape(self, *s, **kwargs): |
| 4753 | """ |
| 4754 | Returns a reshaped masked array without changing its data. |
| 4755 | |
| 4756 | Returns a masked array containing the same data, but with a new shape. |
| 4757 | The result is a view on the original array; if this is not possible, a |
| 4758 | ValueError is raised. |
| 4759 | |
| 4760 | Parameters |
| 4761 | ---------- |
| 4762 | shape : int or tuple of ints |
| 4763 | The new shape should be compatible with the original shape. If an |
| 4764 | integer is supplied, then the result will be a 1-D array of that |
| 4765 | length. |
| 4766 | order : {'C', 'F'}, optional |
| 4767 | Determines whether the array data should be viewed as in C |
| 4768 | (row-major) or FORTRAN (column-major) order. |
| 4769 | |
| 4770 | Returns |
| 4771 | ------- |
| 4772 | reshaped_array : array |
| 4773 | A new view on the array. |
| 4774 | |
| 4775 | See Also |
| 4776 | -------- |
| 4777 | reshape : Equivalent function in the masked array module. |
| 4778 | numpy.ndarray.reshape : Equivalent method on ndarray object. |
| 4779 | numpy.reshape : Equivalent function in the NumPy module. |
| 4780 | |
| 4781 | Notes |
| 4782 | ----- |
| 4783 | By default, the reshaping operation will make a copy if a view |
| 4784 | with different strides is not possible. To ensure a view, |
| 4785 | pass ``copy=False``. |
| 4786 | |
| 4787 | Examples |
| 4788 | -------- |
| 4789 | >>> import numpy as np |
| 4790 | >>> x = np.ma.array([[1,2],[3,4]], mask=[1,0,0,1]) |
| 4791 | >>> x |
| 4792 | masked_array( |
| 4793 | data=[[--, 2], |
| 4794 | [3, --]], |
| 4795 | mask=[[ True, False], |
| 4796 | [False, True]], |
| 4797 | fill_value=999999) |
| 4798 | >>> x = x.reshape((4,1)) |
| 4799 | >>> x |
| 4800 | masked_array( |
| 4801 | data=[[--], |
| 4802 | [2], |
| 4803 | [3], |
| 4804 | [--]], |
| 4805 | mask=[[ True], |
| 4806 | [False], |
| 4807 | [False], |
| 4808 | [ True]], |
| 4809 | fill_value=999999) |