Ejemplo n.º 1
0
 def test01(self):
     """Testing `resize()` (enlarge)"""
     a = np.ones((4, 3), dtype="i4")
     b = bcolz.ones((3, 3), dtype="i4", rootdir=self.rootdir)
     b.resize(4)
     # print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")
Ejemplo n.º 2
0
 def test01(self):
     """Testing `reshape()` (ndim -> unidim)"""
     a = np.ones(12, dtype="i4")
     c = bcolz.ones(12, dtype="i4").reshape((3, 4))
     b = c.reshape(12)
     # print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")
Ejemplo n.º 3
0
 def test02(self):
     """Testing `iter()` (w/ start, stop, step)"""
     a = np.ones((3,), dtype="i4")
     b = bcolz.ones((1000, 3), dtype="i4")
     # print "b->", `b`
     for r in b.iter(15, 100, 3):
         assert_array_equal(a, r, "Arrays are not equal")
Ejemplo n.º 4
0
 def test02(self):
     """Testing `ones` constructor"""
     a = np.ones((2, 2), dtype='(4,)i4')
     b = bcolz.ones((2, 2), dtype='(4,)i4', rootdir=self.rootdir)
     if self.open:
         b = bcolz.open(rootdir=self.rootdir)
     # print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")
Ejemplo n.º 5
0
 def test02(self):
     """Testing unicode types (iter)"""
     a = np.ones((3,), dtype="U40")
     b = bcolz.ones((1000, 3), dtype="U40")
     # print "b->", `b`
     for r in b.iter():
         # print "r-->", r
         assert_array_equal(a, r, "Arrays are not equal")
Ejemplo n.º 6
0
 def test00(self):
     """Testing compound types (creation)"""
     a = np.ones((300, 4), dtype=self.dtype)
     b = bcolz.ones((300, 4), dtype=self.dtype)
     # print "b.dtype-->", b.dtype
     # print "b->", `b`
     self.assertTrue(a.dtype == b.dtype.base)
     assert_array_equal(a, b[:], "Arrays are not equal")
Ejemplo n.º 7
0
 def test03(self):
     """Testing `reshape()` (0-dim)"""
     a = np.ones((0, 4), dtype="i4")
     b = bcolz.ones(0, dtype="i4").reshape((0, 4))
     # print "b->", `b`
     # The next does not work well for carrays with shape (0,)
     # assert_array_equal(a, b, "Arrays are not equal")
     self.assertTrue(a.dtype.base == b.dtype.base)
     self.assertTrue(a.shape == b.shape + b.dtype.shape)
Ejemplo n.º 8
0
 def test00a(self):
     """Testing wheretrue() in combination with a list constructor"""
     a = bcolz.zeros(self.N, dtype="bool", rootdir=self.rootdir)
     a[30:40] = bcolz.ones(10, dtype="bool")
     alist = list(a)
     blist1 = [r for r in a.wheretrue()]
     self.assertTrue(blist1 == list(range(30, 40)))
     alist2 = list(a)
     self.assertTrue(alist == alist2, "wheretrue() not working correctly")
Ejemplo n.º 9
0
 def test00a(self):
     """Testing wheretrue() in combination with a list constructor"""
     a = bcolz.zeros(self.N, dtype="bool", rootdir=self.rootdir)
     a[30:40] = bcolz.ones(10, dtype="bool")
     alist = list(a)
     blist1 = [r for r in a.wheretrue()]
     self.assertTrue(blist1 == list(range(30, 40)))
     alist2 = list(a)
     self.assertTrue(alist == alist2, "wheretrue() not working correctly")
Ejemplo n.º 10
0
 def test00b(self):
     """Testing `resize()` (trim to zero)"""
     a = np.ones((0, 3), dtype="i4")
     b = bcolz.ones((3, 3), dtype="i4", rootdir=self.rootdir)
     b.resize(0)
     # print "b->", `b`
     # The next does not work well for carrays with shape (0,)
     # assert_array_equal(a, b, "Arrays are not equal")
     self.assertTrue("a.dtype.base == b.dtype.base")
     self.assertTrue("a.shape == b.shape+b.dtype.shape")
Ejemplo n.º 11
0
 def test01a(self):
     """Testing where() in combination with a list constructor"""
     a = bcolz.zeros(self.N, dtype="bool")
     a[30:40] = bcolz.ones(10, dtype="bool")
     b = bcolz.arange(self.N, dtype="f4")
     blist = list(b)
     blist1 = [r for r in b.where(a)]
     self.assert_(blist1 == range(30,40))
     blist2 = list(b)
     self.assert_(blist == blist2, "where() not working correctly")
Ejemplo n.º 12
0
    def is_in_ordered_subgroups(self, basket_col=None, bool_arr=None,
                                _max_len_subgroup=1000):
        """"""
        assert basket_col is not None

        if bool_arr is None:
            bool_arr = bcolz.ones(self.len)

        return \
            ctable_ext.is_in_ordered_subgroups(
                self[basket_col], bool_arr=bool_arr,
                _max_len_subgroup=_max_len_subgroup)
Ejemplo n.º 13
0
 def test01(self):
     """Testing `iterblocks()` (w/ start, stop)"""
     a = np.ones((2, 3), dtype="i4")
     b = bcolz.ones((1000, 3), dtype="i4")
     # print "b->", `b`
     l, s = 0, 0
     for block in bcolz.iterblocks(b, blen=2, start=10, stop=100):
         assert_array_equal(a, block, "Arrays are not equal")
         l += len(block)
         s += block.sum()
     self.assertEqual(l, 90)
     # as per Gauss summation formula
     self.assertEqual(s, 90 * 3)
Ejemplo n.º 14
0
 def test01(self):
     """Testing `iterblocks()` (w/ start, stop)"""
     a = np.ones((2,3), dtype="i4")
     b = bcolz.ones((1000, 3), dtype="i4")
     # print "b->", `b`
     l, s = 0, 0
     for block in bcolz.iterblocks(b, blen=2, start=10, stop=100):
         assert_array_equal(a, block, "Arrays are not equal")
         l += len(block)
         s += block.sum()
     self.assertEqual(l, 90)
     # as per Gauss summation formula
     self.assertEqual(s, 90*3)
Ejemplo n.º 15
0
 def test00(self):
     """Testing `iterblocks()` (no start, stop, step)"""
     N = 1000
     a = np.ones((2,3), dtype="i4")
     b = bcolz.ones((N, 3), dtype="i4")
     # print "b->", `b`
     l, s = 0, 0
     for block in bcolz.iterblocks(b, blen=2):
         assert_array_equal(a, block, "Arrays are not equal")
         l += len(block)
         s += block.sum()
     self.assertEqual(l, N)
     # as per Gauss summation formula
     self.assertEqual(s, N*3)
Ejemplo n.º 16
0
 def test00(self):
     """Testing `iterblocks()` (no start, stop, step)"""
     N = 1000
     a = np.ones((2, 3), dtype="i4")
     b = bcolz.ones((N, 3), dtype="i4")
     # print "b->", `b`
     l, s = 0, 0
     for block in bcolz.iterblocks(b, blen=2):
         assert_array_equal(a, block, "Arrays are not equal")
         l += len(block)
         s += block.sum()
     self.assertEqual(l, N)
     # as per Gauss summation formula
     self.assertEqual(s, N * 3)
Ejemplo n.º 17
0
    def is_in_ordered_subgroups(self,
                                basket_col=None,
                                bool_arr=None,
                                _max_len_subgroup=1000):
        """"""
        assert basket_col is not None

        if bool_arr is None:
            bool_arr = bcolz.ones(self.len)

        return \
            ctable_ext.is_in_ordered_subgroups(
                self[basket_col], bool_arr=bool_arr,
                _max_len_subgroup=_max_len_subgroup)
Ejemplo n.º 18
0
 def test01b(self):
     """Testing where() with a multidimensional array"""
     a = bcolz.zeros((self.N, 10), dtype="bool", rootdir=self.rootdir)
     a[30:40] = bcolz.ones(10, dtype="bool")
     b = bcolz.arange(self.N * 10, dtype="f4").reshape((self.N, 10))
     self.assertRaises(NotImplementedError, b.where, a)
Ejemplo n.º 19
0
 def test00b(self):
     """Testing wheretrue() with a multidimensional array"""
     a = bcolz.zeros((self.N, 10), dtype="bool", rootdir=self.rootdir)
     a[30:40] = bcolz.ones(10, dtype="bool")
     self.assertRaises(NotImplementedError, a.wheretrue)
Ejemplo n.º 20
0
 def test01b(self):
     """Testing where() with a multidimensional array"""
     a = bcolz.zeros((self.N, 10), dtype="bool", rootdir=self.rootdir)
     a[30:40] = bcolz.ones(10, dtype="bool")
     b = bcolz.arange(self.N * 10, dtype="f4").reshape((self.N, 10))
     self.assertRaises(NotImplementedError, b.where, a)
Ejemplo n.º 21
0
 def test00b(self):
     """Testing wheretrue() with a multidimensional array"""
     a = bcolz.zeros((self.N, 10), dtype="bool", rootdir=self.rootdir)
     a[30:40] = bcolz.ones(10, dtype="bool")
     self.assertRaises(NotImplementedError, a.wheretrue)
Ejemplo n.º 22
0
 def test00c(self):
     """Testing `reshape()` (unidim -> ndim, -1 in newshape (II))"""
     a = np.ones((3, 4), dtype="i4")
     b = bcolz.ones(12, dtype="i4").reshape((3, -1))
     # print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")