Exemplo n.º 1
0
 def test03(self):
     """Testing `trim()` method (complete trim)"""
     a = np.arange(0.)
     b = blz.arange(1e4, rootdir=self.rootdir)
     b.trim(1e4)
     #print "b->", `b`
     self.assert_(len(a) == len(b), "Lengths are not equal")
Exemplo n.º 2
0
 def test01(self):
     """Testing `trim()` method (small chunklen)"""
     b = blz.arange(1e2, chunklen=2, rootdir=self.rootdir)
     b.trim(5)
     a = np.arange(1e2-5)
     #print "b->", `b`
     assert_array_equal(a, b[:], "Arrays are not equal")
Exemplo n.º 3
0
 def test02(self):
     """Testing `trim()` method (large trim)"""
     a = np.arange(2)
     b = blz.arange(1e4, rootdir=self.rootdir)
     b.trim(1e4-2)
     #print "b->", `b`
     assert_array_equal(a, b[:], "Arrays are not equal")
Exemplo n.º 4
0
 def test01a(self):
     """Testing `resize()` method (decrease, large variation)"""
     b = blz.arange(self.N, rootdir=self.rootdir)
     b.resize(3)
     a = np.arange(3)
     #print "b->", `b`
     assert_array_equal(a, b[:], "Arrays are not equal")
Exemplo n.º 5
0
 def test00(self):
     """Testing `trim()` method"""
     b = blz.arange(1e3, rootdir=self.rootdir)
     b.trim(3)
     a = np.arange(1e3-3)
     #print "b->", `b`
     assert_array_equal(a, b[:], "Arrays are not equal")
Exemplo n.º 6
0
 def test02(self):
     """Testing `resize()` method (zero size)"""
     b = blz.arange(self.N, rootdir=self.rootdir)
     b.resize(0)
     a = np.arange(0)
     #print "b->", `b`
     assert_array_equal(a, b[:], "Arrays are not equal")
Exemplo n.º 7
0
 def test02b(self):
     """Testing `reshape()` (ndim -> ndim, II)"""
     a = np.arange(24, dtype="i4").reshape((2, 3, 4))
     c = blz.arange(24, dtype="i4").reshape((4, 3, 2))
     b = c.reshape((2, 3, 4))
     #print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")
Exemplo n.º 8
0
 def test05(self):
     """Testing `trim()` method (trimming zero items)"""
     a = np.arange(1e1)
     b = blz.arange(1e1, rootdir=self.rootdir)
     b.trim(0)
     #print "b->", `b`
     assert_array_equal(a, b[:], "Arrays are not equal")
Exemplo n.º 9
0
 def test02b(self):
     """Testing `reshape()` (ndim -> ndim, II)"""
     a = np.arange(24, dtype="i4").reshape((2,3,4))
     c = blz.arange(24, dtype="i4").reshape((4,3,2))
     b = c.reshape((2,3,4))
     #print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")
Exemplo n.º 10
0
 def test02(self):
     """Testing iter() in combination with a list constructor"""
     b = blz.arange(self.N, dtype="f4")
     blist = list(b)
     blist1 = [r for r in b.iter(3, 10)]
     self.assert_(blist1 == list(range(3, 10)))
     blist2 = list(b)
     self.assert_(blist == blist2, "iter() not working correctly")
Exemplo n.º 11
0
 def test00b(self):
     """Testing `resize()` method (increase)"""
     b = blz.arange(self.N, rootdir=self.rootdir)
     b.resize(self.N+3)
     a = np.arange(self.N+3)
     a[self.N:] = 0
     #print "b->", `b`
     assert_array_equal(a, b[:], "Arrays are not equal")
Exemplo n.º 12
0
 def test00a(self):
     """Testing `barray` reshape"""
     a = np.arange(16).reshape((2,2,4))
     b = blz.arange(16, rootdir=self.rootdir).reshape((2,2,4))
     if self.open:
         b = blz.open(rootdir=self.rootdir)
     #print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")
Exemplo n.º 13
0
 def test00b(self):
     """Testing `barray` reshape (large shape)"""
     a = np.arange(16000).reshape((20,20,40))
     b = blz.arange(16000, rootdir=self.rootdir).reshape((20,20,40))
     if self.open:
         b = blz.open(rootdir=self.rootdir)
     #print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")
Exemplo n.º 14
0
 def test00b(self):
     """Testing `barray` reshape (large shape)"""
     a = np.arange(16000).reshape((20, 20, 40))
     b = blz.arange(16000, rootdir=self.rootdir).reshape((20, 20, 40))
     if self.open:
         b = blz.open(rootdir=self.rootdir)
     #print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")
Exemplo n.º 15
0
 def test02(self):
     """Testing iter() in combination with a list constructor"""
     b = blz.arange(self.N, dtype="f4")
     blist = list(b)
     blist1 = [r for r in b.iter(3,10)]
     self.assert_(blist1 == list(range(3,10)))
     blist2 = list(b)
     self.assert_(blist == blist2, "iter() not working correctly")
Exemplo n.º 16
0
 def test00a(self):
     """Testing `barray` reshape"""
     a = np.arange(16).reshape((2, 2, 4))
     b = blz.arange(16, rootdir=self.rootdir).reshape((2, 2, 4))
     if self.open:
         b = blz.open(rootdir=self.rootdir)
     #print "b->", `b`
     assert_array_equal(a, b, "Arrays are not equal")
Exemplo n.º 17
0
 def test01b(self):
     """Testing `resize()` method (increase, large variation)"""
     b = blz.arange(self.N, dflt=1, rootdir=self.rootdir)
     b.resize(self.N*3)
     a = np.arange(self.N*3)
     a[self.N:] = 1
     #print "b->", `b`
     assert_array_equal(a, b[:], "Arrays are not equal")
Exemplo n.º 18
0
 def test06(self):
     """Testing `trim()` method (negative number of items)"""
     a = np.arange(2e1)
     b = blz.arange(1e1, rootdir=self.rootdir)
     b.trim(-10)
     a[10:] = 0
     #print "b->", `b`
     assert_array_equal(a, b[:], "Arrays are not equal")
Exemplo n.º 19
0
 def test01a(self):
     """Testing where() in combination with a list constructor"""
     a = blz.zeros(self.N, dtype="bool")
     a[30:40] = blz.ones(10, dtype="bool")
     b = blz.arange(self.N, dtype="f4")
     blist = list(b)
     blist1 = [r for r in b.where(a)]
     self.assert_(blist1 == list(range(30, 40)))
     blist2 = list(b)
     self.assert_(blist == blist2, "where() not working correctly")
Exemplo n.º 20
0
 def test01a(self):
     """Testing where() in combination with a list constructor"""
     a = blz.zeros(self.N, dtype="bool")
     a[30:40] = blz.ones(10, dtype="bool")
     b = blz.arange(self.N, dtype="f4")
     blist = list(b)
     blist1 = [r for r in b.where(a)]
     self.assert_(blist1 == list(range(30,40)))
     blist2 = list(b)
     self.assert_(blist == blist2, "where() not working correctly")
Exemplo n.º 21
0
 def test00(self):
     """Testing arange() with only a `stop`."""
     a = np.arange(self.N)
     ac = blz.arange(self.N)
     self.assert_(np.all(a == ac))
Exemplo n.º 22
0
 def test01b(self):
     """Testing where() with a multidimensional array"""
     a = blz.zeros((self.N, 10), dtype="bool")
     a[30:40] = blz.ones(10, dtype="bool")
     b = blz.arange(self.N*10, dtype="f4").reshape((self.N, 10))
     self.assertRaises(NotImplementedError, b.where, a)
Exemplo n.º 23
0
import numpy as np
import blz
from time import time

N = 1e8
dtype = 'i4'

start, stop, step = 5, N, 4

t0 = time()
a = np.arange(start, stop, step, dtype=dtype)
print "Time numpy.arange() --> %.3f" % (time()-t0)

t0 = time()
ac = blz.arange(start, stop, step, dtype=dtype)
print "Time carray.arange() --> %.3f" % (time()-t0)

print "ac-->", `ac`

#assert(np.all(a == ac))
Exemplo n.º 24
0
 def test02(self):
     """Testing arange() with a `start`, `stop` and `step`."""
     a = np.arange(3, self.N, 4)
     ac = blz.arange(3, self.N, 4)
     self.assert_(np.all(a == ac))
Exemplo n.º 25
0
 def test03(self):
     """Testing arange() with a `dtype`."""
     a = np.arange(self.N, dtype="i1")
     ac = blz.arange(self.N, dtype="i1")
     self.assert_(np.all(a == ac))
Exemplo n.º 26
0
 def test01b(self):
     """Testing where() with a multidimensional array"""
     a = blz.zeros((self.N, 10), dtype="bool")
     a[30:40] = blz.ones(10, dtype="bool")
     b = blz.arange(self.N * 10, dtype="f4").reshape((self.N, 10))
     self.assertRaises(NotImplementedError, b.where, a)
Exemplo n.º 27
0
 def test04(self):
     """Testing `trim()` method (trimming more than available items)"""
     a = np.arange(0.)
     b = blz.arange(1e4, rootdir=self.rootdir)
     #print "b->", `b`
     self.assertRaises(ValueError, b.trim, 1e4+1)