def test02(self): """Testing `append()` method (several rows)""" a = np.ones((4,3), dtype="i4")*3 b = blz.fill((1,3), 3, dtype="i4", rootdir=self.rootdir) b.append([(3,3,3)]*3) #print "b->", `b` assert_array_equal(a, b, "Arrays are not equal")
def test00b(self): """Testing `append()` method (correct shape, single row)""" a = np.ones((2,300), dtype="i4")*3 b = blz.fill((1,300), 3, dtype="i4", rootdir=self.rootdir) b.append((3,)*300) #print "b->", `b` assert_array_equal(a, b, "Arrays are not equal")
def test03b(self): """Testing `fill` constructor (array default)""" a = np.ones((2,2), dtype='(4,)i4')*3 b = blz.fill((2,2), [3,3,3,3], dtype='(4,)i4', rootdir=self.rootdir) if self.open: b = blz.open(rootdir=self.rootdir) #print "b->", `b` assert_array_equal(a, b, "Arrays are not equal")
def test00b(self): """Testing `__getitem()__` method with only a start (slice)""" a = np.ones((27,2700), dtype="i4")*3 b = blz.fill((27,2700), 3, dtype="i4", rootdir=self.rootdir) if self.open: b = blz.open(rootdir=self.rootdir) sl = slice(1) self.assert_(a[sl].shape == b[sl].shape, "Shape is not equal") assert_array_equal(a[sl], b[sl], "Arrays are not equal")
def test04(self): """Testing `fill` constructor with open and resize (array default)""" a = np.ones((3,200), dtype='(4,)i4')*3 b = blz.fill((2,200), [3,3,3,3], dtype='(4,)i4', rootdir=self.rootdir) if self.open: b = blz.open(rootdir=self.rootdir) c = np.ones((1,200), dtype='(4,)i4')*3 b.append(c) #print "b->", `b`, len(b), b[1] assert_array_equal(a, b, "Arrays are not equal")
def test02(self): """Testing `__getitem()__` method with a start, stop, step""" a = np.ones((10,2), dtype="i4")*3 b = blz.fill((10,2), 3, dtype="i4", rootdir=self.rootdir) if self.open: b = blz.open(rootdir=self.rootdir) sl = slice(1,9,2) #print "b[sl]->", `b[sl]` self.assert_(a[sl].shape == b[sl].shape, "Shape is not equal") assert_array_equal(a[sl], b[sl], "Arrays are not equal")
def test00a(self): """Testing `__getitem()__` method with only a start (scalar)""" a = np.ones((2,3), dtype="i4")*3 b = blz.fill((2,3), 3, dtype="i4", rootdir=self.rootdir) if self.open: b = blz.open(rootdir=self.rootdir) sl = 1 #print "b[sl]->", `b[sl]` self.assert_(a[sl].shape == b[sl].shape, "Shape is not equal") assert_array_equal(a[sl], b[sl], "Arrays are not equal")
def test02b(self): """Testing `__setitem()__` method with start,stop,step (scalar)""" a = np.ones((10,2), dtype="i4")*3 b = blz.fill((10,2), 3, dtype="i4", rootdir=self.rootdir) sl = slice(1,8,3) a[sl,:] = range(2) b[sl] = range(2) if self.open: b.flush() b = blz.open(rootdir=self.rootdir) #print "b[sl]->", `b[sl]`, `b` assert_array_equal(a[sl], b[sl], "Arrays are not equal")
def test00b(self): """Testing `__setitem()__` method with only a start (vector)""" a = np.ones((200,300), dtype="i4")*3 b = blz.fill((200,300), 3, dtype="i4", rootdir=self.rootdir) sl = slice(1) a[sl,:] = range(300) b[sl] = range(300) if self.open: b.flush() b = blz.open(rootdir=self.rootdir) #print "b[sl]->", `b[sl]` assert_array_equal(a[sl], b[sl], "Arrays are not equal")
def test05(self): """Testing `fill` constructor with open and resize (nchunks>1)""" a = np.ones((3,2000), dtype='(4,)i4')*3 b = blz.fill((2,2000), [3,3,3,3], dtype='(4,)i4', rootdir=self.rootdir) if self.open: b = blz.open(rootdir=self.rootdir) c = np.ones((1,2000), dtype='(4,)i4')*3 b.append(c) #print "b->", `b` # We need to use the b[:] here to overcome a problem with the # assert_array_equal() function assert_array_equal(a, b[:], "Arrays are not equal")
def test01a(self): """Testing `__setitem()__` method with start,stop (scalar)""" a = np.ones((500,200), dtype="i4")*3 b = blz.fill((500,200), 3, dtype="i4", rootdir=self.rootdir, bparams=blz.bparams()) sl = slice(100,400) a[sl,:] = 0 b[sl] = 0 if self.open: b.flush() b = blz.open(rootdir=self.rootdir) #print "b[sl]->", `b[sl]` assert_array_equal(a[sl], b[sl], "Arrays are not equal")
def test01(self): """Testing `append()` method (incorrect shape)""" a = np.ones((2,3), dtype="i4")*3 b = blz.fill((1,3), 3, dtype="i4", rootdir=self.rootdir) self.assertRaises(ValueError, b.append, [(3,3)])