当前位置: 首页>>代码示例>>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;未经允许,请勿转载。