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

Function compress_cols

numpy/ma/extras.py:994–1032  ·  view source on GitHub ↗

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

(a)

Source from the content-addressed store, hash-verified

992
993
994def compress_cols(a):
995 """
996 Suppress whole columns of a 2-D array that contain masked values.
997
998 This is equivalent to ``np.ma.compress_rowcols(a, 1)``, see
999 `compress_rowcols` for details.
1000
1001 Parameters
1002 ----------
1003 x : array_like, MaskedArray
1004 The array to operate on. If not a MaskedArray instance (or if no array
1005 elements are masked), `x` is interpreted as a MaskedArray with
1006 `mask` set to `nomask`. Must be a 2D array.
1007
1008 Returns
1009 -------
1010 compressed_array : ndarray
1011 The compressed array.
1012
1013 See Also
1014 --------
1015 compress_rowcols
1016
1017 Examples
1018 --------
1019 >>> import numpy as np
1020 >>> a = np.ma.array(np.arange(9).reshape(3, 3), mask=[[1, 0, 0],
1021 ... [1, 0, 0],
1022 ... [0, 0, 0]])
1023 >>> np.ma.compress_cols(a)
1024 array([[1, 2],
1025 [4, 5],
1026 [7, 8]])
1027
1028 """
1029 a = asarray(a)
1030 if a.ndim != 2:
1031 raise NotImplementedError("compress_cols works for 2D arrays only.")
1032 return compress_rowcols(a, 1)
1033
1034
1035def mask_rowcols(a, axis=None):

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…