本文整理汇总了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)
示例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)
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')
示例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')