当前位置: 首页>>代码示例>>Python>>正文


Python utils.assert_array_compare方法代码示例

本文整理汇总了Python中numpy.testing.utils.assert_array_compare方法的典型用法代码示例。如果您正苦于以下问题:Python utils.assert_array_compare方法的具体用法?Python utils.assert_array_compare怎么用?Python utils.assert_array_compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy.testing.utils的用法示例。


在下文中一共展示了utils.assert_array_compare方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: assert_array_compare

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def assert_array_compare(comparison, x, y, err_msg='', verbose=True, header='',
                         fill_value=True):
    """
    Asserts that comparison between two masked arrays is satisfied.

    The comparison is elementwise.

    """
    # Allocate a common mask and refill
    m = mask_or(getmask(x), getmask(y))
    x = masked_array(x, copy=False, mask=m, keep_mask=False, subok=False)
    y = masked_array(y, copy=False, mask=m, keep_mask=False, subok=False)
    if ((x is masked) and not (y is masked)) or \
            ((y is masked) and not (x is masked)):
        msg = build_err_msg([x, y], err_msg=err_msg, verbose=verbose,
                            header=header, names=('x', 'y'))
        raise ValueError(msg)
    # OK, now run the basic tests on filled versions
    return utils.assert_array_compare(comparison,
                                      x.filled(fill_value),
                                      y.filled(fill_value),
                                      err_msg=err_msg,
                                      verbose=verbose, header=header) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:25,代码来源:testutils.py

示例2: assert_array_compare

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def assert_array_compare(comparison, x, y, err_msg='', verbose=True, header='',
                         fill_value=True):
    """Asserts that a comparison relation between two masked arrays is satisfied
    elementwise."""
    # Fill the data first
#    xf = filled(x)
#    yf = filled(y)
    # Allocate a common mask and refill
    m = mask_or(getmask(x), getmask(y))
    x = masked_array(x, copy=False, mask=m, keep_mask=False, subok=False)
    y = masked_array(y, copy=False, mask=m, keep_mask=False, subok=False)
    if ((x is masked) and not (y is masked)) or \
        ((y is masked) and not (x is masked)):
        msg = build_err_msg([x, y], err_msg=err_msg, verbose=verbose,
                            header=header, names=('x', 'y'))
        raise ValueError(msg)
    # OK, now run the basic tests on filled versions
    return utils.assert_array_compare(comparison,
                                      x.filled(fill_value),
                                      y.filled(fill_value),
                                      err_msg=err_msg,
                                      verbose=verbose, header=header) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:testutils.py

示例3: assert_array_equal

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def assert_array_equal(x, y, err_msg='', verbose=True):
    """
    Checks the elementwise equality of two masked arrays.

    """
    assert_array_compare(operator.__eq__, x, y,
                         err_msg=err_msg, verbose=verbose,
                         header='Arrays are not equal') 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:10,代码来源:testutils.py

示例4: fail_if_array_equal

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def fail_if_array_equal(x, y, err_msg='', verbose=True):
    """
    Raises an assertion error if two masked arrays are not equal elementwise.

    """
    def compare(x, y):
        return (not np.alltrue(approx(x, y)))
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
                         header='Arrays are not equal') 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:11,代码来源:testutils.py

示例5: assert_array_approx_equal

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def assert_array_approx_equal(x, y, decimal=6, err_msg='', verbose=True):
    """
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    """
    def compare(x, y):
        "Returns the result of the loose comparison between x and y)."
        return approx(x, y, rtol=10. ** -decimal)
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
                         header='Arrays are not almost equal') 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:14,代码来源:testutils.py

示例6: assert_array_almost_equal

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def assert_array_almost_equal(x, y, decimal=6, err_msg='', verbose=True):
    """
    Checks the equality of two masked arrays, up to given number odecimals.

    The equality is checked elementwise.

    """
    def compare(x, y):
        "Returns the result of the loose comparison between x and y)."
        return almost(x, y, decimal)
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
                         header='Arrays are not almost equal') 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:14,代码来源:testutils.py

示例7: assert_array_equal

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def assert_array_equal(x, y, err_msg='', verbose=True):
    """Checks the elementwise equality of two masked arrays."""
    assert_array_compare(operator.__eq__, x, y,
                         err_msg=err_msg, verbose=verbose,
                         header='Arrays are not equal') 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:testutils.py

示例8: fail_if_array_equal

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def fail_if_array_equal(x, y, err_msg='', verbose=True):
    "Raises an assertion error if two masked arrays are not equal (elementwise)."
    def compare(x, y):
        return (not np.alltrue(approx(x, y)))
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
                         header='Arrays are not equal') 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:testutils.py

示例9: assert_array_approx_equal

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def assert_array_approx_equal(x, y, decimal=6, err_msg='', verbose=True):
    """Checks the elementwise equality of two masked arrays, up to a given
    number of decimals."""
    def compare(x, y):
        "Returns the result of the loose comparison between x and y)."
        return approx(x, y, rtol=10. ** -decimal)
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
                         header='Arrays are not almost equal') 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:testutils.py

示例10: assert_array_almost_equal

# 需要导入模块: from numpy.testing import utils [as 别名]
# 或者: from numpy.testing.utils import assert_array_compare [as 别名]
def assert_array_almost_equal(x, y, decimal=6, err_msg='', verbose=True):
    """Checks the elementwise equality of two masked arrays, up to a given
    number of decimals."""
    def compare(x, y):
        "Returns the result of the loose comparison between x and y)."
        return almost(x, y, decimal)
    assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose,
                         header='Arrays are not almost equal') 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:testutils.py


注:本文中的numpy.testing.utils.assert_array_compare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。