本文整理汇总了Python中numpy.core._multiarray_tests.get_fpu_mode方法的典型用法代码示例。如果您正苦于以下问题:Python _multiarray_tests.get_fpu_mode方法的具体用法?Python _multiarray_tests.get_fpu_mode怎么用?Python _multiarray_tests.get_fpu_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.core._multiarray_tests
的用法示例。
在下文中一共展示了_multiarray_tests.get_fpu_mode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pytest_itemcollected
# 需要导入模块: from numpy.core import _multiarray_tests [as 别名]
# 或者: from numpy.core._multiarray_tests import get_fpu_mode [as 别名]
def pytest_itemcollected(item):
"""
Check FPU precision mode was not changed during test collection.
The clumsy way we do it here is mainly necessary because numpy
still uses yield tests, which can execute code at test collection
time.
"""
global _old_fpu_mode
mode = get_fpu_mode()
if _old_fpu_mode is None:
_old_fpu_mode = mode
elif mode != _old_fpu_mode:
_collect_results[item] = (_old_fpu_mode, mode)
_old_fpu_mode = mode
示例2: check_fpu_mode
# 需要导入模块: from numpy.core import _multiarray_tests [as 别名]
# 或者: from numpy.core._multiarray_tests import get_fpu_mode [as 别名]
def check_fpu_mode(request):
"""
Check FPU precision mode was not changed during the test.
"""
old_mode = get_fpu_mode()
yield
new_mode = get_fpu_mode()
if old_mode != new_mode:
raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}"
" during the test".format(old_mode, new_mode))
collect_result = _collect_results.get(request.node)
if collect_result is not None:
old_mode, new_mode = collect_result
raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}"
" when collecting the test".format(old_mode,
new_mode))
示例3: prepareTestCase
# 需要导入模块: from numpy.core import _multiarray_tests [as 别名]
# 或者: from numpy.core._multiarray_tests import get_fpu_mode [as 别名]
def prepareTestCase(self, test):
from numpy.core._multiarray_tests import get_fpu_mode
def run(result):
old_mode = get_fpu_mode()
test.test(result)
new_mode = get_fpu_mode()
if old_mode != new_mode:
try:
raise AssertionError(
"FPU mode changed from {0:#x} to {1:#x} during the "
"test".format(old_mode, new_mode))
except AssertionError:
result.addFailure(test, sys.exc_info())
return run
# Class allows us to save the results of the tests in runTests - see runTests
# method docstring for details