test_regression.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:radar 作者: amoose136 项目源码 文件源码
def test_bool_flat_indexing_invalid_nr_elements(self, level=rlevel):
        s = np.ones(10, dtype=float)
        x = np.array((15,), dtype=float)

        def ia(x, s, v):
            x[(s > 0)] = v

        # After removing deprecation, the following are ValueErrors.
        # This might seem odd as compared to the value error below. This
        # is due to the fact that the new code always uses "nonzero" logic
        # and the boolean special case is not taken.
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', DeprecationWarning)
            warnings.simplefilter('ignore', np.VisibleDeprecationWarning)
            self.assertRaises(IndexError, ia, x, s, np.zeros(9, dtype=float))
            self.assertRaises(IndexError, ia, x, s, np.zeros(11, dtype=float))
        # Old special case (different code path):
        self.assertRaises(ValueError, ia, x.flat, s, np.zeros(9, dtype=float))
        self.assertRaises(ValueError, ia, x.flat, s, np.zeros(11, dtype=float))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号