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


Python util.Assert类代码示例

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


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

示例1: test_slice_reduce

 def test_slice_reduce(self):
   x = expr.arange((TEST_SIZE, TEST_SIZE, TEST_SIZE), dtype=np.int)
   nx = np.arange(TEST_SIZE * TEST_SIZE * TEST_SIZE, dtype=np.int).reshape((TEST_SIZE, TEST_SIZE, TEST_SIZE))
   y = x[:, :, 0].sum()
   val = y.glom()
   
   Assert.all_eq(val, nx[:, :, 0].sum())
开发者ID:EasonLiao,项目名称:spartan,代码行数:7,代码来源:test_slice.py

示例2: test_reshape8

 def test_reshape8(self):
   t1 = expr.sparse_diagonal((137, 113))
   t2 = expr.sparse_diagonal((113, 137))
   a = expr.reshape(t1, (113, 137))
   b = expr.reshape(t2, (137, 113))
   Assert.all_eq(a.glom().todense(), sp.eye(137, 113).tolil().reshape((113, 137)).todense())
   Assert.all_eq(b.glom().todense(), sp.eye(113, 137).tolil().reshape((137, 113)).todense())
开发者ID:MaggieQi,项目名称:spartan,代码行数:7,代码来源:test_reshape.py

示例3: test_reshape6

 def test_reshape6(self):
   a = expr.arange((12319, ))
   b = expr.reshape(a, (127, 97))
   c = expr.reshape(b, (97, 127))
   d = expr.reshape(c, (1, 12319))
   e = expr.arange((1, 12319))
   Assert.all_eq(d.glom(), e.glom())
开发者ID:MaggieQi,项目名称:spartan,代码行数:7,代码来源:test_reshape.py

示例4: test_reshape5

 def test_reshape5(self):
   a = expr.arange((35511, ))
   b = expr.reshape(a, (133, 267))
   c = expr.reshape(b, (267, 133))
   d = expr.reshape(c, (1, 35511))
   e = expr.arange((1, 35511))
   Assert.all_eq(d.glom(), e.glom())
开发者ID:MaggieQi,项目名称:spartan,代码行数:7,代码来源:test_reshape.py

示例5: test_creation

 def test_creation(self):
     A = spartan.eye(100, 10)
     nA = np.eye(100, 10)
     B = spartan.identity(100)
     nB = np.identity(100)
     Assert.all_eq(A.glom(), nA)
     Assert.all_eq(B.glom(), nB)
开发者ID:GabrielWen,项目名称:spartan,代码行数:7,代码来源:test_creation.py

示例6: test_fio_path

 def test_fio_path(self):
   self.create_path()
   t1 = expr.randn(100, 100).evaluate()
   expr.save(t1, "fiotest1", self.test_dir2, False)
   expr.pickle(t1, "fiotest2", self.test_dir2, False)
   Assert.all_eq(t1.glom(), expr.load("fiotest1", self.test_dir2, False).glom())
   Assert.all_eq(t1.glom(), expr.unpickle("fiotest2", self.test_dir2, False).glom())
开发者ID:GabrielWen,项目名称:spartan,代码行数:7,代码来源:test_fio.py

示例7: test_transpose3

 def test_transpose3(self):
   t1 = expr.sparse_diagonal((107, 401)).evaluate()
   t2 = expr.sparse_diagonal((401, 107)).evaluate()
   a = expr.transpose(t1)
   b = expr.transpose(t2)
   Assert.all_eq(a.glom().todense(), sp.eye(107, 401).transpose().todense())
   Assert.all_eq(b.glom().todense(), sp.eye(401, 107).transpose().todense())
开发者ID:GabrielWen,项目名称:spartan,代码行数:7,代码来源:test_transpose.py

示例8: test_sum_2d

 def test_sum_2d(self):
   x = expr.arange((TEST_SIZE, TEST_SIZE), dtype=np.int)
   nx = np.arange(TEST_SIZE * TEST_SIZE, dtype=np.int).reshape((TEST_SIZE, TEST_SIZE))
   for axis in [None, 0, 1]:  
     y = x.sum(axis)
     val = y.glom()
     Assert.all_eq(val, nx.sum(axis))
开发者ID:EasonLiao,项目名称:spartan,代码行数:7,代码来源:test_reduce.py

示例9: _test_optimization_ordered

  def _test_optimization_ordered(self):
    na = np.random.rand(1000, 1000)
    nb = np.random.rand(1000, 1000)
    a = expr.from_numpy(na)
    b = expr.from_numpy(nb)

    c = a - b
    d = a + c
    f = c[200:900, 200:900]
    g = d[200:900, 200:900]
    h = f - g
    i = f + h
    j = h[100:500, 100:500]
    k = i[100:500, 100:500]
    l = expr.dot(j, k)
    m = j + k
    n = k - l
    o = n - m
    q = o[100:200, 100:200]

    nc = na - nb
    nd = na + nc
    nf = nc[200:900, 200:900]
    ng = nd[200:900, 200:900]
    nh = nf - ng
    ni = nf + nh
    nj = nh[100:500, 100:500]
    nk = ni[100:500, 100:500]
    nl = np.dot(nj, nk)
    nm = nj + nk
    nn = nk - nl
    no = nn - nm
    nq = no[100:200, 100:200]

    Assert.all_eq(nq, q.optimized().glom(), tolerance = 1e-10)
开发者ID:MaggieQi,项目名称:spartan,代码行数:35,代码来源:test_optimization.py

示例10: test_optimization_map_with_location

  def test_optimization_map_with_location(self):
    FLAGS.opt_parakeet_gen = 1
    def mapper(tile, ex):
      return tile + 10

    a = expr.map_with_location(expr.ones((5, 5)), mapper) + expr.ones((5, 5))
    Assert.isinstance(a.optimized().op, expr.local.ParakeetExpr)
开发者ID:MaggieQi,项目名称:spartan,代码行数:7,代码来源:test_optimization.py

示例11: test_reshape3

 def test_reshape3(self):
   a = expr.arange((100, 100))
   b = expr.reshape(a, (10000,))
   c = expr.reshape(b, (10000, 1))
   d = expr.reshape(c, (1, 10000))
   e = expr.arange((1, 10000))
   Assert.all_eq(d.glom(), e.glom())
开发者ID:MaggieQi,项目名称:spartan,代码行数:7,代码来源:test_reshape.py

示例12: test_argmax_2d

 def test_argmax_2d(self):
   for axis in [1]: #[None, 0, 1]:
     x = expr.arange((TEST_SIZE, TEST_SIZE), dtype=np.int)
     nx = np.arange(TEST_SIZE * TEST_SIZE, dtype=np.int).reshape((TEST_SIZE, TEST_SIZE))
     y = x.argmax(axis=axis)
     val = expr.glom(y)
     Assert.all_eq(val, nx.argmax(axis=axis))
开发者ID:EasonLiao,项目名称:spartan,代码行数:7,代码来源:test_reduce.py

示例13: test_assign_array_like

 def test_assign_array_like(self):
   a = np.zeros((20, 10))
   b = np.ones((10, ))
   region = np.s_[10, ]
   sp_a = assign(from_numpy(a), region, b).glom()
   a[region] = b
   Assert.all_eq(sp_a, a)
开发者ID:GabrielWen,项目名称:spartan,代码行数:7,代码来源:test_assign.py

示例14: test_slices_from_slices

  def test_slices_from_slices(self):
    slices1 = (slice(0, 50), slice(0, 50))
    slices2 = (slice(0, 50), slice(50, 100))
    slices3 = (slice(50, 100), slice(0, 50))
    slices4 = (slice(50, 100), slice(50, 100))
    t1 = expr.randn(100, 100)
    t2 = expr.randn(100, 100)
    t3 = expr.write(t2, slices1, t1, slices1)
    t4 = expr.write(t3, slices2, t1, slices2)
    t5 = expr.write(t4, slices3, t1, slices3)
    t6 = expr.write(t5, slices4, t1, slices4)
    Assert.all_eq(t1.glom(), t6.glom())

    dst = np.arange(0, 2500).reshape(50, 50)
    t11 = expr.write(t1, slices1, dst, slices1)
    t12 = expr.write(t11, slices2, dst, slices1)
    t13 = expr.write(t12, slices3, dst, slices1)
    t14 = expr.write(t13, slices4, dst, slices1)

    tmp = expr.write(expr.randn(100, 100), slices4, dst, slices1)
    t21 = expr.write(t2, slices1, tmp, slices4)
    t22 = expr.write(t21, slices2, tmp, slices4)
    t23 = expr.write(t22, slices3, tmp, slices4)
    t24 = expr.write(t23, slices4, tmp, slices4)
    Assert.all_eq(t14.glom(), t24.glom())
开发者ID:EasonLiao,项目名称:spartan,代码行数:25,代码来源:test_write.py

示例15: test_slice_shuffle

 def test_slice_shuffle(self):
   x = expr.arange((TEST_SIZE, TEST_SIZE))
   z = x[5:8, 5:8]
   z = expr.shuffle(z, add_one_extent) 
   val = z.force()
   nx = np.arange(TEST_SIZE*TEST_SIZE).reshape(TEST_SIZE, TEST_SIZE)
   
   Assert.all_eq(val.glom(), nx[5:8, 5:8] + 1)
开发者ID:EasonLiao,项目名称:spartan,代码行数:8,代码来源:test_slice.py


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