MCPcopy Create free account
hub / github.com/numpy/numpy / compressed

Method compressed

numpy/ma/core.py:3866–3891  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

3864 return result
3865
3866 def compressed(self):
3867 """
3868 Return all the non-masked data as a 1-D array.
3869
3870 Returns
3871 -------
3872 data : ndarray
3873 A new `ndarray` holding the non-masked data is returned.
3874
3875 Notes
3876 -----
3877 The result is **not** a MaskedArray!
3878
3879 Examples
3880 --------
3881 >>> x = np.ma.array(np.arange(5), mask=[0]*2 + [1]*3)
3882 >>> x.compressed()
3883 array([0, 1])
3884 >>> type(x.compressed())
3885 <class 'numpy.ndarray'>
3886
3887 """
3888 data = ndarray.ravel(self._data)
3889 if self._mask is not nomask:
3890 data = data.compress(np.logical_not(ndarray.ravel(self._mask)))
3891 return data
3892
3893 def compress(self, condition, axis=None, out=None):
3894 """

Callers 3

test_compressedMethod · 0.45
compressedFunction · 0.45
notmasked_edgesFunction · 0.45

Calls 2

compressMethod · 0.80
ravelMethod · 0.45

Tested by 1

test_compressedMethod · 0.36