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

Python testing_helpers.expect函数代码示例

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

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



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

示例1: test_set_idx_1d

def test_set_idx_1d():
  idx = 10
  for vec in vecs:
    vec1, vec2 = vec.copy(), vec.copy()
    val = -vec[idx]
    vec2[idx] = val
    expect(set_idx_1d, [vec1, idx, val], vec2)
开发者ID:cournape,项目名称:parakeet,代码行数:7,代码来源:test_indexing.py


示例2: test_constants_across_control_flow

def test_constants_across_control_flow():
  testing_helpers.expect(const_across_control_flow, [True], 1)
  typed_fn = parakeet.typed_repr(const_across_control_flow, [True])
  assert len(typed_fn.body) == 1, "Fn body too long: " + str(typed_fn.body)
  stmt = typed_fn.body[0]
  assert isinstance(stmt, syntax.Return)
  assert isinstance(stmt.value, syntax.Const)
开发者ID:lucciano,项目名称:parakeet,代码行数:7,代码来源:test_optimizations.py


示例3: test_always_true

def test_always_true():
  testing_helpers.expect(always_true_branch, [], 0)
  typed_fn = parakeet.typed_repr(always_true_branch, [])
  assert len(typed_fn.body) == 1, "Fn body too long: " + str(typed_fn.body)
  stmt = typed_fn.body[0]
  assert isinstance(stmt, syntax.Return)
  assert isinstance(stmt.value, syntax.Const)
开发者ID:lucciano,项目名称:parakeet,代码行数:7,代码来源:test_optimizations.py


示例4: test_set_idx_2d

def test_set_idx_2d():
  i = 2
  j = 2
  for mat in matrices:
    mat1, mat2 = mat.copy(), mat.copy()
    val = -mat[i,j]
    mat2[i,j] = val
    expect(set_idx_2d, [mat1, i, j, val], mat2)
开发者ID:cournape,项目名称:parakeet,代码行数:8,代码来源:test_indexing.py


示例5: test_set_idx_3d

def test_set_idx_3d():
  i = 2
  j = 3
  k = 1
  for x in tensors:
    x1, x2 = x.copy(), x.copy()
    val = -x[i, j, k]
    x2[i, j, k] = val
    expect(set_idx_3d, [x1, i, j, k, val], x2)
开发者ID:cournape,项目名称:parakeet,代码行数:9,代码来源:test_indexing.py


示例6: test_assign_slices

def test_assign_slices():
  for m in matrices:
    m_expect = m.copy()
    m_input = m.copy()
    (i,j,k,l) = (0,2,0,4)
    (a,b,c,d) = (1,3,5,9)
    m_expect[i:j, k:l] = m_expect[a:b, c:d]
    expect(assign_slices, [m_input, (i,j,k,l), (a,b,c,d)], m_expect)
    expect(assign_slices, [m_input, (i,j,k,l), (a,b,c,d)], m_expect)
开发者ID:cournape,项目名称:parakeet,代码行数:9,代码来源:test_slices.py


示例7: test_copy_elimination

def test_copy_elimination():
  x = np.array([[1,2,3],[4,5,6]])
  expect(nested_add1, [x], x + 1.0)
  typed_fn = parakeet.typed_repr(nested_add1, [x])
  lowered = lowering.apply(typed_fn)
  n_loops = count_loops(lowered)
  n_expected = 3 if config.opt_loop_unrolling else 2
  assert n_loops <= n_expected, \
      "Too many loops generated! Expected at most 2, got %d" % n_loops
开发者ID:lucciano,项目名称:parakeet,代码行数:9,代码来源:test_optimizations.py


示例8: all_tuples

def all_tuples(f, unpack_args = True):
  """
  Given a function which should act as the identity, test it on multiple tuples
  """

  for t in [ints, mixed, nested2, nested2]:
    if unpack_args:
      expect(f, t, t)
    else:
      expect(f, [t], t)
开发者ID:cournape,项目名称:parakeet,代码行数:10,代码来源:test_tuples.py


示例9: test_implicit_to_float

def test_implicit_to_float():
  expect(implicit_to_float, [1], 1.5)
  expect(implicit_to_float, [True], 1.5)
开发者ID:cournape,项目名称:parakeet,代码行数:3,代码来源:test_cast.py


示例10: test_float_sum

def test_float_sum():
  testing_helpers.expect(my_sum, [float_vec], np.sum(float_vec))
开发者ID:lucciano,项目名称:parakeet,代码行数:2,代码来源:test_reduce.py


示例11: test_bool_sum

def test_bool_sum():
  testing_helpers.expect(my_sum, [bool_vec], np.sum(bool_vec))
开发者ID:lucciano,项目名称:parakeet,代码行数:2,代码来源:test_reduce.py


示例12: test_if_true_const

def test_if_true_const():
  expect(if_true_const, [], 1)
开发者ID:lucciano,项目名称:parakeet,代码行数:2,代码来源:test_simple.py


示例13: test_int_sum

def test_int_sum():
  testing_helpers.expect(my_sum, [int_vec], np.sum(int_vec))
开发者ID:lucciano,项目名称:parakeet,代码行数:2,代码来源:test_reduce.py


示例14: test_assign_first_axis

def test_assign_first_axis():
  for m in matrices:
    m_expect = m.copy()
    m_input = m.copy()
    m_expect[1] = m_expect[2]
    expect(assign_first_axis, [m_input, 1, 2], m_expect)
开发者ID:cournape,项目名称:parakeet,代码行数:6,代码来源:test_slices.py


示例15: test_varargs_return

def test_varargs_return():
  expect(varargs_return, [1,2], (1,2))
开发者ID:lucciano,项目名称:parakeet,代码行数:2,代码来源:test_simple.py


示例16: test_slice_first_axis_matrices

def test_slice_first_axis_matrices():
  for m in matrices:
    expect(implicit_slice_first_axis, [m, 2], m[2])
开发者ID:cournape,项目名称:parakeet,代码行数:3,代码来源:test_slices.py


示例17: test_return_pair

def test_return_pair():
  expect(return_pair, [], (-1.0, 200))
开发者ID:cournape,项目名称:parakeet,代码行数:2,代码来源:test_tuples.py


示例18: test_tuple_lhs_sum

def test_tuple_lhs_sum():
  tuples = [(True, 0, 1.0), (1, True, 0)]
  for t in tuples:
    expect(tuple_lhs_sum, [t], sum(t))
开发者ID:cournape,项目名称:parakeet,代码行数:4,代码来源:test_tuples.py


示例19: test_implicit_to_bool

def test_implicit_to_bool():
  expect(implicit_to_bool, [1], 10)
  expect(implicit_to_bool, [2], 10)
  expect(implicit_to_bool, [0], -10)
  expect(implicit_to_bool, [1.0], 10)
  expect(implicit_to_bool, [2.0], 10)
  expect(implicit_to_bool, [0.0], -10)
开发者ID:cournape,项目名称:parakeet,代码行数:7,代码来源:test_cast.py


示例20: test_varargs_add

def test_varargs_add():
  expect(varargs_add, [1,2], 3)
开发者ID:lucciano,项目名称:parakeet,代码行数:2,代码来源:test_simple.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python super_mox.SuperMoxTestBase类代码示例发布时间:2022-05-27
下一篇:
Python testing_helpers.build_test_backup_info函数代码示例发布时间: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