本文整理汇总了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())
示例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))
示例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())
示例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())
示例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))
示例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))
示例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())
示例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)
示例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)
示例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())
示例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))
示例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))
示例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)
示例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))
示例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))