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


Python _multiarray_tests.test_nditer_too_large方法代码示例

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


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

示例1: test_iter_too_large_with_multiindex

# 需要导入模块: from numpy.core import _multiarray_tests [as 别名]
# 或者: from numpy.core._multiarray_tests import test_nditer_too_large [as 别名]
def test_iter_too_large_with_multiindex():
    # When a multi index is being tracked, the error is delayed this
    # checks the delayed error messages and getting below that by
    # removing an axis.
    base_size = 2**10
    num = 1
    while base_size**num < np.iinfo(np.intp).max:
        num += 1

    shape_template = [1, 1] * num
    arrays = []
    for i in range(num):
        shape = shape_template[:]
        shape[i * 2] = 2**10
        arrays.append(np.empty(shape))
    arrays = tuple(arrays)

    # arrays are now too large to be broadcast. The different modes test
    # different nditer functionality with or without GIL.
    for mode in range(6):
        with assert_raises(ValueError):
            _multiarray_tests.test_nditer_too_large(arrays, -1, mode)
    # but if we do nothing with the nditer, it can be constructed:
    _multiarray_tests.test_nditer_too_large(arrays, -1, 7)

    # When an axis is removed, things should work again (half the time):
    for i in range(num):
        for mode in range(6):
            # an axis with size 1024 is removed:
            _multiarray_tests.test_nditer_too_large(arrays, i*2, mode)
            # an axis with size 1 is removed:
            with assert_raises(ValueError):
                _multiarray_tests.test_nditer_too_large(arrays, i*2 + 1, mode) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:35,代码来源:test_nditer.py


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