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

Function clump_unmasked

numpy/ma/extras.py:2002–2038  ·  view source on GitHub ↗

Return list of slices corresponding to the unmasked clumps of a 1-D array. (A "clump" is defined as a contiguous region of the array). Parameters ---------- a : ndarray A one-dimensional masked array. Returns ------- slices : list of slice The list

(a)

Source from the content-addressed store, hash-verified

2000
2001
2002def clump_unmasked(a):
2003 """
2004 Return list of slices corresponding to the unmasked clumps of a 1-D array.
2005 (A "clump" is defined as a contiguous region of the array).
2006
2007 Parameters
2008 ----------
2009 a : ndarray
2010 A one-dimensional masked array.
2011
2012 Returns
2013 -------
2014 slices : list of slice
2015 The list of slices, one for each continuous region of unmasked
2016 elements in `a`.
2017
2018 Notes
2019 -----
2020 .. versionadded:: 1.4.0
2021
2022 See Also
2023 --------
2024 flatnotmasked_edges, flatnotmasked_contiguous, notmasked_edges
2025 notmasked_contiguous, clump_masked
2026
2027 Examples
2028 --------
2029 >>> a = np.ma.masked_array(np.arange(10))
2030 >>> a[[0, 1, 2, 6, 8, 9]] = np.ma.masked
2031 >>> np.ma.clump_unmasked(a)
2032 [slice(3, 6, None), slice(7, 8, None)]
2033
2034 """
2035 mask = getattr(a, '_mask', nomask)
2036 if mask is nomask:
2037 return [slice(0, a.size)]
2038 return _ezclump(~mask)
2039
2040
2041def clump_masked(a):

Callers 1

test_clump_unmaskedMethod · 0.90

Calls 1

_ezclumpFunction · 0.85

Tested by 1

test_clump_unmaskedMethod · 0.72