MCPcopy Index your code
hub / github.com/numpy/numpy / compress_rows

Function compress_rows

numpy/ma/extras.py:955–991  ·  view source on GitHub ↗

Suppress whole rows of a 2-D array that contain masked values. This is equivalent to ``np.ma.compress_rowcols(a, 0)``, see `compress_rowcols` for details. Parameters ---------- x : array_like, MaskedArray The array to operate on. If not a MaskedArray instance (or i

(a)

Source from the content-addressed store, hash-verified

953
954
955def compress_rows(a):
956 """
957 Suppress whole rows of a 2-D array that contain masked values.
958
959 This is equivalent to ``np.ma.compress_rowcols(a, 0)``, see
960 `compress_rowcols` for details.
961
962 Parameters
963 ----------
964 x : array_like, MaskedArray
965 The array to operate on. If not a MaskedArray instance (or if no array
966 elements are masked), `x` is interpreted as a MaskedArray with
967 `mask` set to `nomask`. Must be a 2D array.
968
969 Returns
970 -------
971 compressed_array : ndarray
972 The compressed array.
973
974 See Also
975 --------
976 compress_rowcols
977
978 Examples
979 --------
980 >>> import numpy as np
981 >>> a = np.ma.array(np.arange(9).reshape(3, 3), mask=[[1, 0, 0],
982 ... [1, 0, 0],
983 ... [0, 0, 0]])
984 >>> np.ma.compress_rows(a)
985 array([[6, 7, 8]])
986
987 """
988 a = asarray(a)
989 if a.ndim != 2:
990 raise NotImplementedError("compress_rows works for 2D arrays only.")
991 return compress_rowcols(a, 0)
992
993
994def compress_cols(a):

Callers

nothing calls this directly

Calls 2

compress_rowcolsFunction · 0.85
asarrayFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…