Ejemplo n.º 1
0
 def test07(self):
     """Testing `wherechunks` method with a `limit`, `skip` parameter"""
     N, M = int(1e4), 101
     ra = np.fromiter(((i, i*2., i*3) for i in xrange(N)), dtype='i4,f8,i8')
     t = blz.btable(ra)
     l, s = 0, 0
     for block in blz.whereblocks(t, 'f1 < f2', limit=N-M-2, skip=M):
         l += len(block)
         s += block['f0'].sum()
     self.assert_(l == N - M - 2)
     self.assert_(s == np.arange(M+1, N-1).sum())
Ejemplo n.º 2
0
 def test00(self):
     """Testing `wherechunks` method with only an expression"""
     N = int(1e4)
     ra = np.fromiter(((i, i*2., i*3) for i in xrange(N)), dtype='i4,f8,i8')
     t = blz.btable(ra)
     l, s = 0, 0
     for block in blz.whereblocks(t, 'f1 < f2'):
         l += len(block)
         s += block['f0'].sum()
     self.assert_(l == N - 1)
     self.assert_(s == (N - 1) * (N / 2))  # Gauss summation formula
Ejemplo n.º 3
0
 def test05(self):
     """Testing `wherechunks` method with a `limit` parameter"""
     N, M = int(1e4), 101
     ra = np.fromiter(((i, i*2., i*3) for i in xrange(N)), dtype='i4,f8,i8')
     t = blz.btable(ra)
     l, s = 0, 0
     for block in blz.whereblocks(t, 'f1 < f2', limit=M):
         l += len(block)
         s += block['f0'].sum()
     self.assert_(l == M)
     self.assert_(s == M * ((M + 1) / 2))  # Gauss summation formula
Ejemplo n.º 4
0
 def test02(self):
     """Testing `wherechunks` method with a `outfields` with 2 fields"""
     N = int(1e4)
     ra = np.fromiter(((i, i, i*3) for i in xrange(N)), dtype='i4,f8,i8')
     t = blz.btable(ra)
     l, s = 0, 0
     for block in blz.whereblocks(t, 'f1 < f2', outfields=('f1','f2')):
         self.assert_(block.dtype.names == ('f1','f2'))
         l += len(block)
         s += block['f1'].sum()
     self.assert_(l == N - 1)
     self.assert_(s == (N - 1) * (N / 2))  # Gauss summation formula
Ejemplo n.º 5
0
 def test01(self):
     """Testing `wherechunks` method with a `blen`"""
     N = int(1e4)
     ra = np.fromiter(((i, i*2., i*3) for i in xrange(N)), dtype='i4,f8,i8')
     t = blz.btable(ra)
     l, s = 0, 0
     for block in blz.whereblocks(t, 'f0 <= f1', blen=100):
         l += len(block)
         # All blocks should be of length 100, except the last one,
         # which should be 0
         self.assert_(len(block) in (0, 100))
         s += block['f0'].sum()
     self.assert_(l == N)
     self.assert_(s == (N - 1) * (N / 2))  # Gauss summation formula