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


Python expr.arange函数代码示例

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


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

示例1: 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

示例2: test_2d_2d

  def test_2d_2d(self):
    #Not dot with vector exactly,
    #just to make sure new feature hasn't break anything

    # Test with row > col
    av = expr.arange((132, 100))
    bv = expr.arange((100, 77))
    na = np.arange(13200).reshape(132, 100)
    nb = np.arange(7700).reshape(100, 77)

    Assert.all_eq(expr.dot(av, bv).glom(),
                  np.dot(na, nb))

    # Test with row < col
    av = expr.arange((67, 100))
    bv = expr.arange((100, 77))
    na = np.arange(6700).reshape(67, 100)
    nb = np.arange(7700).reshape(100, 77)

    Assert.all_eq(expr.dot(av, bv).glom(),
                  np.dot(na, nb))

    #Dot with numpy obj
    cv = expr.arange((77, 100))
    dv = np.arange(8800).reshape(100, 88)
    nc = np.arange(7700).reshape(77, 100)
    nd = np.arange(8800).reshape(100, 88)

    Assert.all_eq(expr.dot(cv, dv).glom(),
                  np.dot(nc, nd))
开发者ID:GabrielWen,项目名称:spartan,代码行数:30,代码来源:test_dot.py

示例3: 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

示例4: 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

示例5: test_2d_vec

  def test_2d_vec(self):
    av = expr.arange((77, 100))
    bv = expr.arange(stop = 100)
    na = np.arange(7700).reshape(77, 100)
    nb = np.arange(100)

    Assert.all_eq(expr.dot(av, bv).glom(),
                  np.dot(na, nb))
开发者ID:xuanhan863,项目名称:spartan,代码行数:8,代码来源:test_dot.py

示例6: test_vec_vec

  def test_vec_vec(self):
    av = expr.arange(stop=100)
    bv = expr.arange(stop=100)
    na = np.arange(100)
    nb = np.arange(100)

    Assert.all_eq(expr.dot(av, bv).glom(),
                  np.dot(na, nb))
开发者ID:GabrielWen,项目名称:spartan,代码行数:8,代码来源:test_dot.py

示例7: test_reshape4

 def test_reshape4(self):
   a = expr.arange((10000, ))
   b = expr.reshape(a, (10, 1000))
   c = expr.reshape(b, (1000, 10))
   d = expr.reshape(c, (20, 500))
   e = expr.reshape(d, (500, 20))
   f = expr.reshape(e, (1, 10000))
   g = expr.arange((1, 10000))
   Assert.all_eq(f.glom(), g.glom())
开发者ID:MaggieQi,项目名称:spartan,代码行数:9,代码来源:test_reshape.py

示例8: test_matmul

  def test_matmul(self):
    x = expr.arange(XDIM, dtype=np.int).astype(np.float64)
    y = expr.arange(YDIM, dtype=np.int).astype(np.float64)
    z = expr.dot(x, y)

    nx = np.arange(np.prod(XDIM), dtype=np.int).reshape(XDIM).astype(np.float64)
    ny = np.arange(np.prod(YDIM), dtype=np.int).reshape(YDIM).astype(np.float64)
    nz = np.dot(nx, ny)

    Assert.all_eq(z.glom(), nz)
开发者ID:EasonLiao,项目名称:spartan,代码行数:10,代码来源:test_matmul.py

示例9: test_reshape7

  def test_reshape7(self):
    t1 = expr.arange((23, 120, 100)).glom()
    t2 = expr.arange((12, 230, 100)).glom()
    t3 = expr.arange((276000, 1)).glom()
    t4 = expr.arange((1, 276000)).glom()

    a = expr.arange((100, 23, 120))
    b = expr.arange((12, 23, 1000))
    c = expr.arange((1, 276000))
    d = expr.arange((276000, 1))
    e = expr.arange((276000, ))

    Assert.all_eq(expr.reshape(a, (23, 120, 100)).glom(), t1)
    Assert.all_eq(expr.reshape(a, (12, 230, 100)).glom(), t2)
    Assert.all_eq(expr.reshape(a, (276000, 1)).glom(), t3)
    Assert.all_eq(expr.reshape(a, (1, 276000)).glom(), t4)
    Assert.all_eq(expr.reshape(b, (23, 120, 100)).glom(), t1)
    Assert.all_eq(expr.reshape(b, (12, 230, 100)).glom(), t2)
    Assert.all_eq(expr.reshape(b, (276000, 1)).glom(), t3)
    Assert.all_eq(expr.reshape(b, (1, 276000)).glom(), t4)
    Assert.all_eq(expr.reshape(c, (23, 120, 100)).glom(), t1)
    Assert.all_eq(expr.reshape(c, (12, 230, 100)).glom(), t2)
    Assert.all_eq(expr.reshape(c, (276000, 1)).glom(), t3)
    Assert.all_eq(expr.reshape(c, (1, 276000)).glom(), t4)
    Assert.all_eq(expr.reshape(d, (23, 120, 100)).glom(), t1)
    Assert.all_eq(expr.reshape(d, (12, 230, 100)).glom(), t2)
    Assert.all_eq(expr.reshape(d, (276000, 1)).glom(), t3)
    Assert.all_eq(expr.reshape(d, (1, 276000)).glom(), t4)
    Assert.all_eq(expr.reshape(e, (23, 120, 100)).glom(), t1)
    Assert.all_eq(expr.reshape(e, (12, 230, 100)).glom(), t2)
    Assert.all_eq(expr.reshape(e, (276000, 1)).glom(), t3)
    Assert.all_eq(expr.reshape(e, (1, 276000)).glom(), t4)
开发者ID:MaggieQi,项目名称:spartan,代码行数:32,代码来源:test_reshape.py

示例10: 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

示例11: 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

示例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_slice_map

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

示例14: test_numpy_vec_2d

  def test_numpy_vec_2d(self):
    av = expr.arange(stop = 100)
    bv = np.arange(7700).reshape(100, 77)
    na = np.arange(100)
    nb = np.arange(7700).reshape(100, 77)

    Assert.all_eq(expr.dot(av, bv).glom(),
                  np.dot(na, nb))
开发者ID:xuanhan863,项目名称:spartan,代码行数:8,代码来源:test_dot.py

示例15: test_argmax_3d

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


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