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

Function getdata

numpy/ma/core.py:671–719  ·  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 a ndarray or subclass (depending on `subok`) if not. Parameters ---------- a : array_like Input ``MaskedArray``, alternati

(a, subok=True)

Source from the content-addressed store, hash-verified

669
670
671def getdata(a, subok=True):
672 """
673 Return the data of a masked array as an ndarray.
674
675 Return the data of `a` (if any) as an ndarray if `a` is a ``MaskedArray``,
676 else return `a` as a ndarray or subclass (depending on `subok`) if not.
677
678 Parameters
679 ----------
680 a : array_like
681 Input ``MaskedArray``, alternatively a ndarray or a subclass thereof.
682 subok : bool
683 Whether to force the output to be a `pure` ndarray (False) or to
684 return a subclass of ndarray if appropriate (True, default).
685
686 See Also
687 --------
688 getmask : Return the mask of a masked array, or nomask.
689 getmaskarray : Return the mask of a masked array, or full array of False.
690
691 Examples
692 --------
693 >>> import numpy.ma as ma
694 >>> a = ma.masked_equal([[1,2],[3,4]], 2)
695 >>> a
696 masked_array(
697 data=[[1, --],
698 [3, 4]],
699 mask=[[False, True],
700 [False, False]],
701 fill_value=2)
702 >>> ma.getdata(a)
703 array([[1, 2],
704 [3, 4]])
705
706 Equivalently use the ``MaskedArray`` `data` attribute.
707
708 >>> a.data
709 array([[1, 2],
710 [3, 4]])
711
712 """
713 try:
714 data = a._data
715 except AttributeError:
716 data = np.array(a, copy=False, subok=subok)
717 if not subok:
718 return data.view(ndarray)
719 return data
720
721
722get_data = getdata

Callers 15

fromarraysFunction · 0.90
__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
__idiv__Method · 0.85
__ifloordiv__Method · 0.85

Calls 1

viewMethod · 0.45

Tested by

no test coverage detected