本文整理汇总了Python中spartan.util.Assert.eq方法的典型用法代码示例。如果您正苦于以下问题:Python Assert.eq方法的具体用法?Python Assert.eq怎么用?Python Assert.eq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spartan.util.Assert
的用法示例。
在下文中一共展示了Assert.eq方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_sparse_to_sparse
# 需要导入模块: from spartan.util import Assert [as 别名]
# 或者: from spartan.util.Assert import eq [as 别名]
def test_update_sparse_to_sparse(self):
t = tile.from_shape(ARRAY_SIZE, dtype=np.float32, tile_type=tile.TYPE_SPARSE)
update = sp.lil_matrix(ARRAY_SIZE, dtype=np.float32)
for i in range(UPDATE_SHAPE[0]):
update[i,i] = 1
t.update(UPDATE_SUBSLICE, update, None)
Assert.eq(sp.issparse(t.data), True)
print t.data.todense()
示例2: test_unravel
# 需要导入模块: from spartan.util import Assert [as 别名]
# 或者: from spartan.util.Assert import eq [as 别名]
def test_unravel():
for i in range(100):
shp = (20, 77)
ul = (random.randint(0, 19), random.randint(0, 76))
lr = (random.randint(ul[0] + 1, 20), random.randint(ul[1] + 1, 77))
a = extent.create(ul, lr, shp)
ravelled = a.ravelled_pos()
unravelled = extent.unravelled_pos(ravelled, a.array_shape)
Assert.eq(a.ul, unravelled)
示例3: test_ravelled_pos
# 需要导入模块: from spartan.util import Assert [as 别名]
# 或者: from spartan.util.Assert import eq [as 别名]
def test_ravelled_pos():
a = extent.create((2, 2), (7, 7), (10, 10))
for i in range(0, 10):
for j in range(0, 10):
assert extent.ravelled_pos((i, j), a.array_shape) == 10 * i + j
Assert.eq(a.to_global(0, axis=None), 22)
Assert.eq(a.to_global(10, axis=None), 42)
Assert.eq(a.to_global(11, axis=None), 43)
Assert.eq(a.to_global(20, axis=None), 62)
示例4: test_fio_sparse
# 需要导入模块: from spartan.util import Assert [as 别名]
# 或者: from spartan.util.Assert import eq [as 别名]
def test_fio_sparse(self):
self.create_path()
t1 = expr.sparse_rand((100, 100)).evaluate()
Assert.eq(expr.save(t1, "fiotest3", self.test_dir, False), True)
Assert.all_eq(t1.glom().todense(), expr.load("fiotest3", self.test_dir, False).glom().todense())
Assert.eq(expr.save(t1, "fiotest3", self.test_dir, True), True)
Assert.all_eq(t1.glom().todense(), expr.load("fiotest3", self.test_dir, True).glom().todense())
Assert.eq(expr.pickle(t1, "fiotest4", self.test_dir, False), True)
Assert.all_eq(t1.glom().todense(), expr.unpickle("fiotest4", self.test_dir, False).glom().todense())
Assert.eq(expr.pickle(t1, "fiotest4", self.test_dir, True), True)
Assert.all_eq(t1.glom().todense(), expr.unpickle("fiotest4", self.test_dir, True).glom().todense())
示例5: test_fio_dense
# 需要导入模块: from spartan.util import Assert [as 别名]
# 或者: from spartan.util.Assert import eq [as 别名]
def test_fio_dense(self):
self.create_path()
t1 = expr.arange((100, 100)).evaluate()
Assert.eq(expr.save(t1, "fiotest1", self.test_dir, False), True)
Assert.all_eq(t1.glom(), expr.load("fiotest1", self.test_dir, False).glom())
Assert.eq(expr.save(t1, "fiotest1", self.test_dir, True), True)
Assert.all_eq(t1.glom(), expr.load("fiotest1", self.test_dir, True).glom())
Assert.eq(expr.pickle(t1, "fiotest2", self.test_dir, False), True)
Assert.all_eq(t1.glom(), expr.unpickle("fiotest2", self.test_dir, False).glom())
Assert.eq(expr.pickle(t1, "fiotest2", self.test_dir, True), True)
Assert.all_eq(t1.glom(), expr.unpickle("fiotest2", self.test_dir, True).glom())
示例6: test_intersection
# 需要导入模块: from spartan.util import Assert [as 别名]
# 或者: from spartan.util.Assert import eq [as 别名]
def test_intersection():
a = extent.create((0, 0), (10, 10), None)
b = extent.create((5, 5), (6, 6), None)
Assert.eq(extent.intersection(a, b),
extent.create((5,5), (6,6), None))
Assert.eq(extent.intersection(b, a),
extent.create((5,5), (6,6), None))
a = extent.create((5, 5), (10, 10), None)
b = extent.create((4, 6), (6, 8), None)
Assert.eq(extent.intersection(a, b),
extent.create((5,6), (6, 8), None))
a = extent.create((5, 5), (5, 5), None)
b = extent.create((1, 1), (2, 2), None)
assert extent.intersection(a, b) == None
示例7: test_create_sparse
# 需要导入模块: from spartan.util import Assert [as 别名]
# 或者: from spartan.util.Assert import eq [as 别名]
def test_create_sparse(self):
t = tile.from_shape(ARRAY_SIZE, dtype=np.float32, tile_type=tile.TYPE_SPARSE)
t._initialize()
Assert.eq(t.data.shape, ARRAY_SIZE)
Assert.eq(t.mask, None)
示例8: test_create_dense
# 需要导入模块: from spartan.util import Assert [as 别名]
# 或者: from spartan.util.Assert import eq [as 别名]
def test_create_dense(self):
t = tile.from_shape(ARRAY_SIZE, dtype=np.float32, tile_type=tile.TYPE_DENSE)
t._initialize()
Assert.eq(t.mask.shape, ARRAY_SIZE)
示例9: test_count_nonzero
# 需要导入模块: from spartan.util import Assert [as 别名]
# 或者: from spartan.util.Assert import eq [as 别名]
def test_count_nonzero(self):
x = expr.ones((TEST_SIZE,))
Assert.eq(expr.count_nonzero(x).glom(), TEST_SIZE)
x = expr.zeros((TEST_SIZE,))
Assert.eq(expr.count_nonzero(x).glom(), 0)