def test_wrong_open_mode(self):
     ddesc = BLZ_DDesc(path=self.rootdir, mode='w')
     a = blaze.ones('10 * float64', ddesc=ddesc)
     # Re-open the dataset
     ddesc = BLZ_DDesc(path=self.rootdir, mode='r')
     self.assertTrue(ddesc.mode == 'r')
     a2 = blaze.array(ddesc)
     self.assertRaises(IOError, append, a2, [1])
 def test_open(self):
     ddesc = BLZ_DDesc(path=self.rootdir, mode='w')
     self.assertTrue(ddesc.mode == 'w')
     a = blaze.ones('0 * float64', ddesc=ddesc)
     append(a, range(10))
     # Re-open the dataset
     ddesc = BLZ_DDesc(path=self.rootdir, mode='r')
     self.assertTrue(ddesc.mode == 'r')
     a2 = blaze.array(ddesc)
     self.assertTrue(isinstance(a2, blaze.Array))
     self.assertEqual(ddesc_as_py(a2.ddesc), list(range(10)))
 def test_append2(self):
     ddesc = BLZ_DDesc(path=self.rootdir, mode='w')
     a = blaze.empty('0 * 2 * float64', ddesc=ddesc)
     self.assertTrue(isinstance(a, blaze.Array))
     lvals = [[i, i * 2] for i in range(10)]
     append(a, lvals)
     self.assertEqual([list(i) for i in a], lvals)
 def test_create_record_compress(self):
     # A simple record array (backed by BLZ)
     ddesc = BLZ_DDesc(mode='w')
     a = blaze.array([(10, 3.5), (15, 2.25)],
                     dshape="var * {val: int32, flt: float32}",
                     ddesc=ddesc)
     self.assertEqual(list(a), [{
         'val': 10,
         'flt': 3.5
     }, {
         'val': 15,
         'flt': 2.25
     }])
     # Test field access via attributes
     aval = a.val
     self.assertEqual(list(aval), [10, 15])
     aflt = a.flt
     self.assertEqual(list(aflt), [3.5, 2.25])
class setitem_blz(getitem):
    ddesc = BLZ_DDesc(mode='w')
 def test_create_compress_iter(self):
     # A compressed array (backed by BLZ)
     ddesc = BLZ_DDesc(mode='w', bparams=blz.bparams(clevel=5))
     a = blaze.array((i for i in range(10)), ddesc=ddesc)
     self.assertTrue(isinstance(a, blaze.Array))
     self.assertEqual(list(a), list(range(10)))
 def test_create_compress(self):
     # A compressed array (backed by BLZ)
     ddesc = BLZ_DDesc(mode='w', bparams=blz.bparams(clevel=5))
     a = blaze.array(np.arange(1, 4), ddesc=ddesc)
     self.assertTrue(isinstance(a, blaze.Array))
     self.assertEqual(list(a), [1, 2, 3])
 def test_append(self):
     ddesc = BLZ_DDesc(path=self.rootdir, mode='w')
     a = blaze.zeros('0 * float64', ddesc=ddesc)
     self.assertTrue(isinstance(a, blaze.Array))
     append(a, list(range(10)))
     self.assertEqual(list(a), list(range(10)))
 def test_create_record(self):
     ddesc = BLZ_DDesc(path=self.rootdir, mode='w')
     a = blaze.array([(1, 2)], '{x: int, y: real}', ddesc=ddesc)
     self.assertTrue(isinstance(a, blaze.Array))
     self.assertTrue(a.dshape.shape == (1, ))
     self.assertEqual(list(a), [{'x': 1, 'y': 2.0}])
 def test_create(self):
     ddesc = BLZ_DDesc(path=self.rootdir, mode='w')
     a = blaze.array([2], 'float64', ddesc=ddesc)
     self.assertTrue(isinstance(a, blaze.Array))
     self.assertTrue(a.dshape.shape == (1, ))
     self.assertEqual(list(a), [2])
 def test_create_compress_ones(self):
     # A compressed array (backed by BLZ)
     ddesc = BLZ_DDesc(mode='w', bparams=blz.bparams(clevel=5))
     a = blaze.ones('10 * int64', ddesc=ddesc)
     self.assertTrue(isinstance(a, blaze.Array))
     self.assertEqual(list(a), [1] * 10)