MCPcopy
hub / github.com/numpy/numpy / getdata

Function getdata

numpy/ma/core.py:720–769  ·  view source on GitHub ↗

Return the data of a masked array as an ndarray. Return the data of `a` (if any) as an ndarray if `a` is a ``MaskedArray``, else return `a` as an ndarray or subclass (depending on `subok`) if not. Parameters ---------- a : array_like Input ``MaskedArray``, alternat

(a, subok=True)

Source from the content-addressed store, hash-verified

718
719
720def getdata(a, subok=True):
721 """
722 Return the data of a masked array as an ndarray.
723
724 Return the data of `a` (if any) as an ndarray if `a` is a ``MaskedArray``,
725 else return `a` as an ndarray or subclass (depending on `subok`) if not.
726
727 Parameters
728 ----------
729 a : array_like
730 Input ``MaskedArray``, alternatively an ndarray or a subclass thereof.
731 subok : bool
732 Whether to force the output to be a `pure` ndarray (False) or to
733 return a subclass of ndarray if appropriate (True, default).
734
735 See Also
736 --------
737 getmask : Return the mask of a masked array, or nomask.
738 getmaskarray : Return the mask of a masked array, or full array of False.
739
740 Examples
741 --------
742 >>> import numpy as np
743 >>> import numpy.ma as ma
744 >>> a = ma.masked_equal([[1,2],[3,4]], 2)
745 >>> a
746 masked_array(
747 data=[[1, --],
748 [3, 4]],
749 mask=[[False, True],
750 [False, False]],
751 fill_value=2)
752 >>> ma.getdata(a)
753 array([[1, 2],
754 [3, 4]])
755
756 Equivalently use the ``MaskedArray`` `data` attribute.
757
758 >>> a.data
759 array([[1, 2],
760 [3, 4]])
761
762 """
763 try:
764 data = a._data
765 except AttributeError:
766 data = np.array(a, copy=None, subok=subok)
767 if not subok:
768 return data.view(ndarray)
769 return data
770
771
772get_data = getdata

Callers 15

__call__Method · 0.85
__call__Method · 0.85
outerMethod · 0.85
__call__Method · 0.85
__setitem__Method · 0.85
_comparisonMethod · 0.85
__iadd__Method · 0.85
__isub__Method · 0.85
__imul__Method · 0.85
__ifloordiv__Method · 0.85
__itruediv__Method · 0.85
__ipow__Method · 0.85

Calls 1

viewMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…