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

Function compressed

numpy/ma/core.py:7057–7092  ·  view source on GitHub ↗

Return all the non-masked data as a 1-D array. This function is equivalent to calling the "compressed" method of a `ma.MaskedArray`, see `ma.MaskedArray.compressed` for details. See Also -------- ma.MaskedArray.compressed : Equivalent method. Examples --------

(x)

Source from the content-addressed store, hash-verified

7055
7056
7057def compressed(x):
7058 """
7059 Return all the non-masked data as a 1-D array.
7060
7061 This function is equivalent to calling the "compressed" method of a
7062 `ma.MaskedArray`, see `ma.MaskedArray.compressed` for details.
7063
7064 See Also
7065 --------
7066 ma.MaskedArray.compressed : Equivalent method.
7067
7068 Examples
7069 --------
7070
7071 Create an array with negative values masked:
7072
7073 >>> import numpy as np
7074 >>> x = np.array([[1, -1, 0], [2, -1, 3], [7, 4, -1]])
7075 >>> masked_x = np.ma.masked_array(x, mask=x < 0)
7076 >>> masked_x
7077 masked_array(
7078 data=[[1, --, 0],
7079 [2, --, 3],
7080 [7, 4, --]],
7081 mask=[[False, True, False],
7082 [False, True, False],
7083 [False, False, True]],
7084 fill_value=999999)
7085
7086 Compress the masked array into a 1-D array of non-masked values:
7087
7088 >>> np.ma.compressed(masked_x)
7089 array([1, 0, 2, 3, 7, 4])
7090
7091 """
7092 return asanyarray(x).compressed()
7093
7094
7095def concatenate(arrays, axis=0):

Callers

nothing calls this directly

Calls 2

asanyarrayFunction · 0.85
compressedMethod · 0.45

Tested by

no test coverage detected