Exemplo n.º 1
0
 def test_io_haskey(self):
     "io_haskey"
     io = IO(self.filename)
     x = larry([1, 2, 3])
     y = larry([7, 8, 9])
     io['x'] = x
     io['y'] = y
     self.assertTrue(io.has_key('x'), 'keys do not match')
     self.assertTrue(io.has_key('y'), 'keys do not match')
     self.assertTrue(~io.has_key('z'), 'keys do not match')
Exemplo n.º 2
0
 def test_io_haskey(self):
     "io_haskey"
     io = IO(self.filename)
     x = larry([1,2,3])
     y = larry([7,8,9])
     io['x'] = x
     io['y'] = y
     self.assertTrue(io.has_key('x'), 'keys do not match')
     self.assertTrue(io.has_key('y'), 'keys do not match')
     self.assertTrue(~io.has_key('z'), 'keys do not match')
Exemplo n.º 3
0
 def test_io_iterkeys(self):
     "io_iterkeys"
     io = IO(self.filename)
     x = larry([1,2,3])
     y = larry([7,8,9])
     io['x'] = x
     io['y'] = y
     itk = io.iterkeys()
     keys = [k for k in itk]
     self.assertTrue(keys == ['x', 'y'], 'keys do not match')
Exemplo n.º 4
0
 def test_io_iterkeys(self):
     "io_iterkeys"
     io = IO(self.filename)
     x = larry([1, 2, 3])
     y = larry([7, 8, 9])
     io['x'] = x
     io['y'] = y
     itk = io.iterkeys()
     keys = [k for k in itk]
     self.assertTrue(keys == ['x', 'y'], 'keys do not match')
Exemplo n.º 5
0
 def test_io_itervalues(self):
     "io_itervalues"
     io = IO(self.filename)
     x = larry([1,2,3])
     y = larry([7,8,9])
     io['x'] = x
     io['y'] = y
     itv = io.itervalues()
     values = [v[:] for v in itv]
     assert_larry_equal(values[0], x)
     assert_larry_equal(values[1], y)
Exemplo n.º 6
0
 def test_io_3(self):
     "io_keys"
     io = IO(self.filename)
     io["1"] = larry([1, 2, 3])
     io["2"] = larry([1, 2, 3])
     io.f["3"] = [1, 2, 3]
     io["1/2/3/4"] = larry([1, 2, 3])
     keys = io.keys()
     keys.sort()
     theory = ["1", "1/2/3/4", "2"]
     self.assert_(keys == theory, "keys do not match")
Exemplo n.º 7
0
 def test_io_3(self):
     "io_keys"
     io = IO(self.filename)
     io['1'] = larry([1, 2, 3])
     io['2'] = larry([1, 2, 3])
     io.f['3'] = [1, 2, 3]
     io['1/2/3/4'] = larry([1, 2, 3])
     keys = io.keys()
     keys.sort()
     theory = ['1', '1/2/3/4', '2']
     self.assert_(keys == theory, 'keys do not match')
Exemplo n.º 8
0
 def test_io_3(self):
     "io_keys"
     io = IO(self.filename)                
     io['1'] = larry([1,2,3])
     io['2'] = larry([1,2,3])
     io.f['3'] = [1,2,3]
     io['1/2/3/4'] = larry([1,2,3])
     keys = io.keys()
     keys.sort()
     theory = ['1', '1/2/3/4', '2']
     self.assertTrue(keys == theory, 'keys do not match')
Exemplo n.º 9
0
 def test_io_itervalues(self):
     "io_itervalues"
     io = IO(self.filename)
     x = larry([1, 2, 3])
     y = larry([7, 8, 9])
     io['x'] = x
     io['y'] = y
     itv = io.itervalues()
     values = [v[:] for v in itv]
     assert_larry_equal(values[0], x)
     assert_larry_equal(values[1], y)
Exemplo n.º 10
0
 def test_io_1(self):
     "io_general"
     io = IO(self.filename)
     x = larry([1, 2, 3])
     io["x"] = x
     self.assert_("x" in io, "key missing")
     self.assert_((x == io["x"][:]).all(), "save and load difference")
     self.assert_(["x"] == io.keys(), "keys are different")
     self.assert_(x.dtype == io["x"].dtype, "dtype changed")
     del io["x"]
     self.assert_(io.keys() == [], "key still present")
Exemplo n.º 11
0
 def test_io_1(self):
     "io_general"
     io = IO(self.filename)
     x = larry([1, 2, 3])
     io['x'] = x
     self.assertTrue('x' in io, 'key missing')
     self.assertTrue((x == io['x'][:]).all(), 'save and load difference')
     self.assertTrue(['x'] == list(io.keys()), 'keys are different')
     self.assertTrue(x.dtype == io['x'].dtype, 'dtype changed')
     del io['x']
     self.assertTrue(list(io.keys()) == [], 'key still present')
Exemplo n.º 12
0
 def test_io_1(self):
     "io_general"
     io = IO(self.filename)
     x = larry([1,2,3]) 
     io['x'] = x
     self.assertTrue('x' in io, 'key missing')
     self.assertTrue((x == io['x'][:]).all(), 'save and load difference')
     self.assertTrue(['x'] == io.keys(), 'keys are different')
     self.assertTrue(x.dtype == io['x'].dtype, 'dtype changed')
     del io['x']
     self.assertTrue(io.keys() == [], 'key still present')
Exemplo n.º 13
0
 def test_io_2(self):
     "io_repack"
     io = IO(self.filename)                
     io['larry'] = la.rand(100, 100)
     fs1 = io.freespace
     sp1 = io.space
     del io['larry']
     io.repack()
     fs2 = io.freespace
     sp2 = io.space
     self.assertTrue(fs2 < fs1, 'repack did not reduce freespace')
     self.assertTrue(sp2 < sp1, 'repack did not reduce space')
Exemplo n.º 14
0
 def test_io_2(self):
     "io_repack"
     io = IO(self.filename)
     io['larry'] = la.rand(100, 100)
     fs1 = io.freespace
     sp1 = io.space
     del io['larry']
     io.repack()
     fs2 = io.freespace
     sp2 = io.space
     self.assertTrue(fs2 < fs1, 'repack did not reduce freespace')
     self.assertTrue(sp2 < sp1, 'repack did not reduce space')
Exemplo n.º 15
0
 def test_io_2(self):
     "io_repack"
     io = IO(self.filename)
     io["larry"] = la.rand(100, 100)
     fs1 = io.freespace
     sp1 = io.space
     del io["larry"]
     io.repack()
     fs2 = io.freespace
     sp2 = io.space
     self.assert_(fs2 < fs1, "repack did not reduce freespace")
     self.assert_(sp2 < sp1, "repack did not reduce space")
Exemplo n.º 16
0
 def test_io_items(self):
     "io_items"
     io = IO(self.filename)
     x = larry([1,2,3])
     y = larry([7,8,9])
     io['x'] = x
     io['y'] = y
     items = io.items()
     values = [v[1][:] for v in items]
     assert_larry_equal(values[0], x)
     assert_larry_equal(values[1], y)
     keys = [v[0] for v in items]
     self.assertTrue(keys == ['x', 'y'], 'keys do not match')
Exemplo n.º 17
0
 def test_io_3(self):
     "io_keys"
     io = IO(self.filename)
     io['1'] = larry([1,2,3])
     io['2'] = larry([1,2,3])
     f = h5py.File(self.filename)
     f['3'] = [1,2,3]
     f.close()
     io['1/2/3/4'] = larry([1,2,3])
     keys = list(io.keys())
     keys.sort()
     theory = ['1', '1/2/3/4', '2']
     self.assertTrue(keys == theory, 'keys do not match')
Exemplo n.º 18
0
 def test_io_3(self):
     "io_keys"
     io = IO(self.filename)
     io['1'] = larry([1, 2, 3])
     io['2'] = larry([1, 2, 3])
     f = h5py.File(self.filename)
     f['3'] = [1, 2, 3]
     f.close()
     io['1/2/3/4'] = larry([1, 2, 3])
     keys = list(io.keys())
     keys.sort()
     theory = ['1', '1/2/3/4', '2']
     self.assertTrue(keys == theory, 'keys do not match')
Exemplo n.º 19
0
 def test_io_items(self):
     "io_items"
     io = IO(self.filename)
     x = larry([1, 2, 3])
     y = larry([7, 8, 9])
     io['x'] = x
     io['y'] = y
     items = io.items()
     values = [v[1][:] for v in items]
     assert_larry_equal(values[0], x)
     assert_larry_equal(values[1], y)
     keys = [v[0] for v in items]
     self.assertTrue(keys == ['x', 'y'], 'keys do not match')
Exemplo n.º 20
0
 def test_io_lara_1(self):
     "lara indexing bug #40"
     io = IO(self.filename)
     io['a'] = la.lrange(3)
     b = io['a']
     # b[[0, 2]] raised:
     # AttributeError: 'Dataset' object has no attribute 'take'
     b[[0, 2]]
Exemplo n.º 21
0
 def test_io_len(self):
     "io_len"
     io = IO(self.filename)
     x = larry([1, 2, 3])
     y = larry([7, 8, 9])
     io['x'] = x
     io['y'] = y
     self.assertTrue(len(io) == 2, 'number of keys is wrong')
Exemplo n.º 22
0
 def test_io_4(self):
     "io_dates"
     io = IO(self.filename)
     x = [1, 2]
     label = [[datetime.date(2010, 3, 1), datetime.date(2010, 3, 2)]]
     desired = larry(x, label)
     io['desired'] = desired
     actual = io['desired'][:]
     assert_larry_equal(actual, desired)
Exemplo n.º 23
0
 def test_io_7(self):
     "io_empty (gh #68)"
     io = IO(self.filename)
     desired = larry([])
     io['desired'] = desired
     actual = io['desired']
     if actual.size == 0:
         actual = la.larry([])
     assert_larry_equal(actual, desired)
Exemplo n.º 24
0
 def test_io_6(self):
     "io_datetimes"
     io = IO(self.filename)
     x = [1, 2]
     label = [[datetime.time(13, 15, 59, 9998), datetime.time(11, 23)]]
     desired = larry(x, label)
     io['desired'] = desired
     actual = io['desired'][:]
     assert_larry_equal(actual, desired)