本文整理匯總了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