• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utilities.check函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中test.utilities.check函数的典型用法代码示例。如果您正苦于以下问题:Python check函数的具体用法?Python check怎么用?Python check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_slice_1d_2

def test_slice_1d_2(dtype):
    def test(a, b): a[:5] = b[3:8]
    (ao, ah), (b, _) = random(dtype, [10]), random(dtype, [10])
    test(ao, b), hope.jit(test)(ah, b)
    assert check(ao, ah)
    test(ao, b), hope.jit(test)(ah, b)
    assert check(ao, ah)
开发者ID:BrainGrylls,项目名称:hope,代码行数:7,代码来源:test_slice.py


示例2: test_cls_1

def test_cls_1():
    inst = Cls()
    inst.fkt_1()
    assert check(inst.af, inst.res)
    inst.af = np.array([1, 2, 3], dtype=np.int_)
    inst.fkt_1()
    assert check(inst.af, inst.res)
开发者ID:BrainGrylls,项目名称:hope,代码行数:7,代码来源:test_object.py


示例3: test_slice_1d_3

def test_slice_1d_3(dtype):
    def fkt(a, b): a[2:] = b[1:9]
    (ao, ah), (b, _) = random(dtype, [10]), random(dtype, [10])
    fkt(ao, b), hope.jit(fkt)(ah, b)
    assert check(ao, ah)
    fkt(ao, b), hope.jit(fkt)(ah, b)
    assert check(ao, ah)
开发者ID:cosmo-ethz,项目名称:hope,代码行数:7,代码来源:test_slice.py


示例4: test_fkt_call_scalar_jit_multi

def test_fkt_call_scalar_jit_multi(dtype):
    hfkt = hope.jit(fkt_call_scalar_jit_multi_fkt)
    (a, _), (c, _) = random(dtype, []), random(dtype, [])
    c = hfkt(a)
    assert check(c, a + 1)
    c = hfkt(a)
    assert check(c, a + 1)
开发者ID:BrainGrylls,项目名称:hope,代码行数:7,代码来源:test_call.py


示例5: test_index_2d

def test_index_2d(dtype):
    def fkt(a, b): a[4, 2] = b[3, 4]
    (ao, ah), (b, _) = random(dtype, [5, 5]), random(dtype, [5, 5])
    fkt(ao, b), hope.jit(fkt)(ah, b)
    assert check(ao, ah)
    fkt(ao, b), hope.jit(fkt)(ah, b)
    assert check(ao, ah)
开发者ID:cosmo-ethz,项目名称:hope,代码行数:7,代码来源:test_slice.py


示例6: test_index_1d

def test_index_1d(dtype):
    def fkt(a, b): a[5] = b[3]
    (ao, ah), (b, _) = random(dtype, [10]), random(dtype, [10])
    fkt(ao, b), hope.jit(fkt)(ah, b)
    assert check(ao, ah)
    fkt(ao, b), hope.jit(fkt)(ah, b)
    assert check(ao, ah)
开发者ID:cosmo-ethz,项目名称:hope,代码行数:7,代码来源:test_slice.py


示例7: test_assignment

def test_assignment(dtype):
    def fkt(a, b): a[:] = b
    (ao, ah), (b, _) = random(dtype, [10]), random(dtype, [10])
    fkt(ao, b), hope.jit(fkt)(ah, b)
    assert check(ao, ah)
    fkt(ao, b), hope.jit(fkt)(ah, b)
    assert check(ao, ah)
开发者ID:cosmo-ethz,项目名称:hope,代码行数:7,代码来源:test_slice.py


示例8: test_cross_div

def test_cross_div(dtypea, dtypeb, dtypec):
    if dtypea == np.int8 and dtypeb == np.int8:
        pytest.skip("Different behaviour in c++ and python for int8 / int8".format(dtypea, dtypeb))

    def fkt(a, b, c):
        c[:] = a / b

    hfkt = hope.jit(fkt)
    (ao, ah), (bo, bh), (co, ch) = random(dtypea, [10]), random(dtypeb, [10]), random(dtypec, [10])
    ao, ah, bo, bh = ao.astype(np.float64), ah.astype(np.float64), bo.astype(np.float64), bh.astype(np.float64)
    ao, ah = (
        np.copysign(np.power(np.abs(ao), 1.0 / 4.0), ao).astype(dtypea),
        np.copysign(np.power(np.abs(ah), 1.0 / 4.0), ah).astype(dtypea),
    )
    bo, bh = (
        np.copysign(np.power(np.abs(bo), 1.0 / 4.0), bo).astype(dtypeb),
        np.copysign(np.power(np.abs(bh), 1.0 / 4.0), bh).astype(dtypeb),
    )
    if np.count_nonzero(bo == 0) > 0:
        bo[bo == 0] += 1
    if np.count_nonzero(bh == 0) > 0:
        bh[bh == 0] += 1
    fkt(ao, bo, co), hfkt(ah, bh, ch)
    assert check(co, ch)
    fkt(ao, bo, co), hfkt(ah, bh, ch)
    assert check(co, ch)
开发者ID:you13,项目名称:hope,代码行数:26,代码来源:test_op_div.py


示例9: test_index_2d_2

def test_index_2d_2(dtype):
    def fkt(a): a[1:4, 1:4] = 1
    (ao, ah) = random(dtype, [5, 5])
    
    fkt(ao), hope.jit(fkt)(ah)
    assert check(ao, ah)
    fkt(ao), hope.jit(fkt)(ah)
    assert check(ao, ah)
开发者ID:cosmo-ethz,项目名称:hope,代码行数:8,代码来源:test_slice.py


示例10: test_call_scalar_jit_fun_return

def test_call_scalar_jit_fun_return(dtype):
    def fkt(a):
        return fkt_call_scalar_jit_fun_return_callback(a)
    hfkt = hope.jit(fkt)
    (ao, ah), (co, ch) = random(dtype, []), random(dtype, [])
    co, ch = fkt(ao), hfkt(ah)
    assert check(co, ch)
    co, ch = fkt(ao), hfkt(ah)
    assert check(co, ch)
开发者ID:BrainGrylls,项目名称:hope,代码行数:9,代码来源:test_call.py


示例11: test_binary_rshift

def test_binary_rshift(dtype, shape):
    def fkt(a, b, c):
        c[:] = a >> b
    hfkt = hope.jit(fkt)
    (ao, ah), (bo, bh), (co, ch) = random(dtype, shape), random(dtype, shape), random(dtype, shape)
    bo, bh = (bo % (np.dtype(dtype).itemsize * 8)).astype(dtype), (bh % (np.dtype(dtype).itemsize * 8)).astype(dtype)
    fkt(ao, bo, co),  hfkt(ah, bh, ch)
    assert check(co, ch)
    fkt(ao, bo, co),  hfkt(ah, bh, ch)
    assert check(co, ch)
开发者ID:BrainGrylls,项目名称:hope,代码行数:10,代码来源:test_operators.py


示例12: test_call_local_fun

def test_call_local_fun(dtype, shape):
    def fkt(a, b, c):
        fkt_call_local_fun_callback(a, b)
        c[:] = a
    hfkt = hope.jit(fkt)
    (ao, ah), (bo, bh), (co, ch) = random(dtype, shape), random(dtype, shape), random(dtype, shape)
    fkt(ao, bo, co),  hfkt(ah, bh, ch)
    assert check(co, ch)
    fkt(ao, bo, co),  hfkt(ah, bh, ch)
    assert check(co, ch)
开发者ID:BrainGrylls,项目名称:hope,代码行数:10,代码来源:test_call.py


示例13: test_binary_pow

def test_binary_pow(dtype, shape):
    def fkt(a, c):
        c[:] = a ** 2
    hfkt = hope.jit(fkt)
    (ao, ah), (co, ch) = random(dtype, shape), random(dtype, shape)
    ao, ah = np.copysign(np.sqrt(np.abs(ao)), ao).astype(dtype), np.copysign(np.sqrt(np.abs(ah)), ah).astype(dtype)
    fkt(ao, co),  hfkt(ah, ch)
    assert check(co, ch)
    fkt(ao, co),  hfkt(ah, ch)
    assert check(co, ch)
开发者ID:BrainGrylls,项目名称:hope,代码行数:10,代码来源:test_op_pow.py


示例14: test_augmented_rshift

def test_augmented_rshift(dtype, shape):
    def fkt(a, c):
        c[:] >>= a
    hfkt = hope.jit(fkt)
    (ao, ah), (co, ch) = random(dtype, [10]), random(dtype, [10])
    ao, ah = (ao % (np.dtype(dtype).itemsize * 8)).astype(dtype), (ah % (np.dtype(dtype).itemsize * 8)).astype(dtype)
    fkt(ao, co),  hfkt(ah, ch)
    assert check(co, ch)
    fkt(ao, co),  hfkt(ah, ch)
    assert check(co, ch)
开发者ID:BrainGrylls,项目名称:hope,代码行数:10,代码来源:test_operators.py


示例15: test_binary_minus

def test_binary_minus(dtype, shape):
    def fkt(a, b, c):
        c[:] = a - b
    hfkt = hope.jit(fkt)
    (ao, ah), (bo, bh), (co, ch) = random(dtype, shape), random(dtype, shape), random(dtype, shape)
    ao, ah, bo, bh = (ao / 2.).astype(dtype), (ah / 2.).astype(dtype), (bo / 2.).astype(dtype), (bh / 2.).astype(dtype)
    ro, rh = fkt(ao, bo, co),  hfkt(ah, bh, ch)
    assert check(co, ch)
    ro, rh = fkt(ao, bo, co),  hfkt(ah, bh, ch)
    assert check(co, ch)
开发者ID:BrainGrylls,项目名称:hope,代码行数:10,代码来源:test_op_minus.py


示例16: test_func_sum_var

def test_func_sum_var(dtype, shape):
    def fkt(a):
        return np.sum(a)
    hfkt = hope.jit(fkt)
    ao, ah = random(dtype, shape)
    ao, ah = ao / 1200, ah / 1200
    co, ch = fkt(ao), hfkt(ah)
    assert check(co, ch)
    co, ch = fkt(ao), hfkt(ah)
    assert check(co, ch)
开发者ID:BrainGrylls,项目名称:hope,代码行数:10,代码来源:test_functions.py


示例17: test_augmented_minus

def test_augmented_minus(dtype, shape):
    def fkt(a, c):
        c[:] -= a
    hfkt = hope.jit(fkt)
    (ao, ah), (co, ch) = random(dtype, shape), random(dtype, shape)
    ao, ah, co, ch = (ao / 4.).astype(dtype), (ah / 4.).astype(dtype), (co / 2.).astype(dtype), (ch / 2.).astype(dtype)
    ro, rh = fkt(ao, co),  hfkt(ah, ch)
    assert check(co, ch)
    ro, rh = fkt(ao, co),  hfkt(ah, ch)
    assert check(co, ch)
开发者ID:BrainGrylls,项目名称:hope,代码行数:10,代码来源:test_op_minus.py


示例18: test_merged_slice

def test_merged_slice(dtype):
    def fkt(a, b, c):
        for i in range(10):
            c[:, i] = a[i, :]
    hfkt = hope.jit(fkt)
    (ao, ah), (bo, bh), (co, ch) = random(dtype, [10, 10]), random(dtype, [10, 10]), random(dtype, [10, 10])
    ao, ah, bo, bh = (ao / 2.).astype(dtype), (ah / 2.).astype(dtype), (bo / 2.).astype(dtype), (bh / 2.).astype(dtype)
    fkt(ao, bo, co), hfkt(ah, bh, ch)
    assert check(co, ch)
    fkt(ao, bo, co), hfkt(ah, bh, ch)
    assert check(co, ch)
开发者ID:cosmo-ethz,项目名称:hope,代码行数:11,代码来源:test_slice.py


示例19: test_for_range_2

def test_for_range_2(dtype):
    def fkt(a, b, c):
        for i in range(0, 10):
            c[:, i] = a[i, :]
            c[i, 1] = a[0, 1] + b[i, 5]
    hfkt = hope.jit(fkt)
    (ao, ah), (bo, bh), (co, ch) = random(dtype, [10, 10]), random(dtype, [10, 10]), random(dtype, [10, 10])
    ao, ah, bo, bh = (ao / 2.).astype(dtype), (ah / 2.).astype(dtype), (bo / 2.).astype(dtype), (bh / 2.).astype(dtype)
    assert check(co, ch)
    ro, rh = fkt(ao, bo, co), hfkt(ah, bh, ch)
    assert check(co, ch)
开发者ID:CSRedRat,项目名称:hope,代码行数:11,代码来源:test_control_structures.py


示例20: test_augmented_mult

def test_augmented_mult(dtype, shape):
    def fkt(a, c):
        c[:] *= a
    hfkt = hope.jit(fkt)
    (ao, ah), (co, ch) = random(dtype, shape), random(dtype, shape)
    ao, ah = np.copysign(np.power(np.abs(ao), 1. / 4.), ao).astype(dtype), np.copysign(np.power(np.abs(ah), 1. / 4.), ah).astype(dtype)
    co, ch = np.copysign(np.power(np.abs(co), 1. / 4.), co).astype(dtype), np.copysign(np.power(np.abs(ch), 1. / 4.), ch).astype(dtype)
    ro, rh = fkt(ao, co),  hfkt(ah, ch)
    assert check(co, ch)
    ro, rh = fkt(ao, co),  hfkt(ah, ch)
    assert check(co, ch)
开发者ID:BrainGrylls,项目名称:hope,代码行数:11,代码来源:test_op_mult.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utilities.random函数代码示例发布时间:2022-05-27
下一篇:
Python util.result_lines函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap