Return all the non-masked data as a 1-D array. Returns ------- data : ndarray A new `ndarray` holding the non-masked data is returned. Notes ----- The result is **not** a MaskedArray! Examples -------- >>
(self)
| 3936 | return result |
| 3937 | |
| 3938 | def compressed(self): |
| 3939 | """ |
| 3940 | Return all the non-masked data as a 1-D array. |
| 3941 | |
| 3942 | Returns |
| 3943 | ------- |
| 3944 | data : ndarray |
| 3945 | A new `ndarray` holding the non-masked data is returned. |
| 3946 | |
| 3947 | Notes |
| 3948 | ----- |
| 3949 | The result is **not** a MaskedArray! |
| 3950 | |
| 3951 | Examples |
| 3952 | -------- |
| 3953 | >>> import numpy as np |
| 3954 | >>> x = np.ma.array(np.arange(5), mask=[0]*2 + [1]*3) |
| 3955 | >>> x.compressed() |
| 3956 | array([0, 1]) |
| 3957 | >>> type(x.compressed()) |
| 3958 | <class 'numpy.ndarray'> |
| 3959 | |
| 3960 | N-D arrays are compressed to 1-D. |
| 3961 | |
| 3962 | >>> arr = [[1, 2], [3, 4]] |
| 3963 | >>> mask = [[1, 0], [0, 1]] |
| 3964 | >>> x = np.ma.array(arr, mask=mask) |
| 3965 | >>> x.compressed() |
| 3966 | array([2, 3]) |
| 3967 | |
| 3968 | """ |
| 3969 | data = ndarray.ravel(self._data) |
| 3970 | if self._mask is not nomask: |
| 3971 | data = data.compress(np.logical_not(ndarray.ravel(self._mask))) |
| 3972 | return data |
| 3973 | |
| 3974 | def compress(self, condition, axis=None, out=None): |
| 3975 | """ |