def test02(self): """Testing copy() with lower clevel""" N = 10*1000 ra = np.fromiter(((i, i**2.2) for i in xrange(N)), dtype='i4,f8') t = blz.btable(ra, rootdir=self.rootdir) t2 = t.copy(bparams=blz.bparams(clevel=1)) self.assert_(t.bparams.clevel == blz.bparams().clevel) self.assert_(t2.bparams.clevel == 1) #print "cbytes in f1, f2:", t['f1'].cbytes, t2['f1'].cbytes self.assert_(t['f1'].cbytes < t2['f1'].cbytes, "clevel not changed")
def test03(self): """Testing copy() with no shuffle""" a = np.linspace(-1., 1., 1e4) b = blz.barray(a, rootdir=self.rootdir) c = b.copy(bparams=blz.bparams(shuffle=False)) #print "b.cbytes, c.cbytes:", b.cbytes, c.cbytes self.assert_(b.cbytes < c.cbytes, "shuffle not changed")
def test02(self): """Testing copy() with lesser compression""" a = np.linspace(-1., 1., 1e4) b = blz.barray(a, rootdir=self.rootdir) c = b.copy(bparams=blz.bparams(clevel=1)) #print "b.cbytes, c.cbytes:", b.cbytes, c.cbytes self.assert_(b.cbytes < c.cbytes, "clevel not changed")
def test01b(self): """Testing bparams when adding a new column (numpy flavor)""" N = 10 ra = np.fromiter(((i, i*2.) for i in xrange(N)), dtype='i4,f8') t = blz.btable(ra, bparams=blz.bparams(1), rootdir=self.rootdir) c = np.arange(N, dtype='i8')*3 t.addcol(c, 'f2') self.assert_(t['f2'].bparams.clevel == 1, "Incorrect clevel")
def test03(self): """Testing copy() with no shuffle""" N = 10*1000 ra = np.fromiter(((i, i**2.2) for i in xrange(N)), dtype='i4,f8') t = blz.btable(ra) # print "t:", t, t.rootdir t2 = t.copy(bparams=blz.bparams(shuffle=False), rootdir=self.rootdir) #print "cbytes in f1, f2:", t['f1'].cbytes, t2['f1'].cbytes self.assert_(t['f1'].cbytes < t2['f1'].cbytes, "clevel not changed")
def test01(self): """Testing copy() with higher clevel""" N = 10*1000 ra = np.fromiter(((i, i**2.2) for i in xrange(N)), dtype='i4,f8') t = blz.btable(ra, rootdir=self.rootdir) if self.disk: # Copy over the same location should give an error self.assertRaises(RuntimeError, t.copy,bparams=blz.bparams(clevel=9), rootdir=self.rootdir, mode='w') return else: t2 = t.copy(bparams=blz.bparams(clevel=9), rootdir=self.rootdir, mode='w') #print "cbytes in f1, f2:", t['f1'].cbytes, t2['f1'].cbytes self.assert_(t.bparams.clevel == blz.bparams().clevel) self.assert_(t2.bparams.clevel == 9) self.assert_(t['f1'].cbytes > t2['f1'].cbytes, "clevel not changed")
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 test04(self): """Testing `__getitem()__` method with long ranges""" a = np.arange(1e4) b = chunk(a, atom=a.dtype, bparams=blz.bparams()) #print "b[1:8000]->", `b[1:8000]` assert_array_equal(a[1:8000], b[1:8000], "Arrays are not equal")
def test03(self): """Testing `__getitem()__` method with ranges and steps""" a = np.arange(1e3) b = chunk(a, atom=a.dtype, bparams=blz.bparams()) #print "b[1:8:3]->", `b[1:8:3]` assert_array_equal(a[1:8:3], b[1:8:3], "Arrays are not equal")
def test01(self): """Testing `__getitem()__` method with scalars""" a = np.arange(1e3) b = chunk(a, atom=a.dtype, bparams=blz.bparams()) #print "b[1]->", `b[1]` self.assert_(a[1] == b[1], "Values in key 1 are not equal")