當前位置: 首頁>>代碼示例>>Python>>正文


Python mrecords.MaskedRecords方法代碼示例

本文整理匯總了Python中numpy.ma.mrecords.MaskedRecords方法的典型用法代碼示例。如果您正苦於以下問題:Python mrecords.MaskedRecords方法的具體用法?Python mrecords.MaskedRecords怎麽用?Python mrecords.MaskedRecords使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy.ma.mrecords的用法示例。


在下文中一共展示了mrecords.MaskedRecords方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _fix_output

# 需要導入模塊: from numpy.ma import mrecords [as 別名]
# 或者: from numpy.ma.mrecords import MaskedRecords [as 別名]
def _fix_output(output, usemask=True, asrecarray=False):
    """
    Private function: return a recarray, a ndarray, a MaskedArray
    or a MaskedRecords depending on the input parameters
    """
    if not isinstance(output, MaskedArray):
        usemask = False
    if usemask:
        if asrecarray:
            output = output.view(MaskedRecords)
    else:
        output = ma.filled(output)
        if asrecarray:
            output = output.view(recarray)
    return output 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:17,代碼來源:recfunctions.py

示例2: test_wmasked_arrays

# 需要導入模塊: from numpy.ma import mrecords [as 別名]
# 或者: from numpy.ma.mrecords import MaskedRecords [as 別名]
def test_wmasked_arrays(self):
        # Test merge_arrays masked arrays
        (_, x, _, _) = self.data
        mx = ma.array([1, 2, 3], mask=[1, 0, 0])
        test = merge_arrays((x, mx), usemask=True)
        control = ma.array([(1, 1), (2, 2), (-1, 3)],
                           mask=[(0, 1), (0, 0), (1, 0)],
                           dtype=[('f0', int), ('f1', int)])
        assert_equal(test, control)
        test = merge_arrays((x, mx), usemask=True, asrecarray=True)
        assert_equal(test, control)
        assert_(isinstance(test, MaskedRecords)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:14,代碼來源:test_recfunctions.py

示例3: recfromtxt

# 需要導入模塊: from numpy.ma import mrecords [as 別名]
# 或者: from numpy.ma.mrecords import MaskedRecords [as 別名]
def recfromtxt(fname, **kwargs):
    """
    Load ASCII data from a file and return it in a record array.

    If ``usemask=False`` a standard `recarray` is returned,
    if ``usemask=True`` a MaskedRecords array is returned.

    Parameters
    ----------
    fname, kwargs : For a description of input parameters, see `genfromtxt`.

    See Also
    --------
    numpy.genfromtxt : generic function

    Notes
    -----
    By default, `dtype` is None, which means that the data-type of the output
    array will be determined from the data.

    """
    kwargs.setdefault("dtype", None)
    usemask = kwargs.get('usemask', False)
    output = genfromtxt(fname, **kwargs)
    if usemask:
        from numpy.ma.mrecords import MaskedRecords
        output = output.view(MaskedRecords)
    else:
        output = output.view(np.recarray)
    return output 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:32,代碼來源:npyio.py

示例4: recfromcsv

# 需要導入模塊: from numpy.ma import mrecords [as 別名]
# 或者: from numpy.ma.mrecords import MaskedRecords [as 別名]
def recfromcsv(fname, **kwargs):
    """
    Load ASCII data stored in a comma-separated file.

    The returned array is a record array (if ``usemask=False``, see
    `recarray`) or a masked record array (if ``usemask=True``,
    see `ma.mrecords.MaskedRecords`).

    Parameters
    ----------
    fname, kwargs : For a description of input parameters, see `genfromtxt`.

    See Also
    --------
    numpy.genfromtxt : generic function to load ASCII data.

    Notes
    -----
    By default, `dtype` is None, which means that the data-type of the output
    array will be determined from the data.

    """
    # Set default kwargs for genfromtxt as relevant to csv import.
    kwargs.setdefault("case_sensitive", "lower")
    kwargs.setdefault("names", True)
    kwargs.setdefault("delimiter", ",")
    kwargs.setdefault("dtype", None)
    output = genfromtxt(fname, **kwargs)

    usemask = kwargs.get("usemask", False)
    if usemask:
        from numpy.ma.mrecords import MaskedRecords
        output = output.view(MaskedRecords)
    else:
        output = output.view(np.recarray)
    return output 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:38,代碼來源:npyio.py

示例5: test_wmasked_arrays

# 需要導入模塊: from numpy.ma import mrecords [as 別名]
# 或者: from numpy.ma.mrecords import MaskedRecords [as 別名]
def test_wmasked_arrays(self):
        "Test merge_arrays masked arrays"
        (_, x, _, _) = self.data
        mx = ma.array([1, 2, 3], mask=[1, 0, 0])
        test = merge_arrays((x, mx), usemask=True)
        control = ma.array([(1, 1), (2, 2), (-1, 3)],
                           mask=[(0, 1), (0, 0), (1, 0)],
                           dtype=[('f0', int), ('f1', int)])
        assert_equal(test, control)
        test = merge_arrays((x, mx), usemask=True, asrecarray=True)
        assert_equal(test, control)
        assert_(isinstance(test, MaskedRecords))
    # 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:15,代碼來源:test_recfunctions.py

示例6: recfromtxt

# 需要導入模塊: from numpy.ma import mrecords [as 別名]
# 或者: from numpy.ma.mrecords import MaskedRecords [as 別名]
def recfromtxt(fname, **kwargs):
    """
    Load ASCII data from a file and return it in a record array.

    If ``usemask=False`` a standard `recarray` is returned,
    if ``usemask=True`` a MaskedRecords array is returned.

    Parameters
    ----------
    fname, kwargs : For a description of input parameters, see `genfromtxt`.

    See Also
    --------
    numpy.genfromtxt : generic function

    Notes
    -----
    By default, `dtype` is None, which means that the data-type of the output
    array will be determined from the data.

    """
    kwargs.update(dtype=kwargs.get('dtype', None))
    usemask = kwargs.get('usemask', False)
    output = genfromtxt(fname, **kwargs)
    if usemask:
        from numpy.ma.mrecords import MaskedRecords
        output = output.view(MaskedRecords)
    else:
        output = output.view(np.recarray)
    return output 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:32,代碼來源:npyio.py

示例7: recfromcsv

# 需要導入模塊: from numpy.ma import mrecords [as 別名]
# 或者: from numpy.ma.mrecords import MaskedRecords [as 別名]
def recfromcsv(fname, **kwargs):
    """
    Load ASCII data stored in a comma-separated file.

    The returned array is a record array (if ``usemask=False``, see
    `recarray`) or a masked record array (if ``usemask=True``,
    see `ma.mrecords.MaskedRecords`).

    Parameters
    ----------
    fname, kwargs : For a description of input parameters, see `genfromtxt`.

    See Also
    --------
    numpy.genfromtxt : generic function to load ASCII data.

    """
    case_sensitive = kwargs.get('case_sensitive', "lower") or "lower"
    names = kwargs.get('names', True)
    if names is None:
        names = True
    kwargs.update(dtype=kwargs.get('update', None),
                  delimiter=kwargs.get('delimiter', ",") or ",",
                  names=names,
                  case_sensitive=case_sensitive)
    usemask = kwargs.get("usemask", False)
    output = genfromtxt(fname, **kwargs)
    if usemask:
        from numpy.ma.mrecords import MaskedRecords
        output = output.view(MaskedRecords)
    else:
        output = output.view(np.recarray)
    return output 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:35,代碼來源:npyio.py


注:本文中的numpy.ma.mrecords.MaskedRecords方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。