1
# Eh! python!, We are going to include isolatin characters here
2
# -*- coding: latin-1 -*-
10
from numarray import strings
19
from test_all import verbose, allequal
21
class BasicTestCase(unittest.TestCase):
33
complib = "zlib" # Default compression library
36
reopen = 1 # Tells whether the file has to be reopened on each test or not
40
# Create an instance of an HDF5 Table
41
self.file = tempfile.mktemp(".h5")
42
self.fileh = openFile(self.file, "w")
43
self.rootgroup = self.fileh.root
49
def populateFile(self):
50
group = self.rootgroup
51
if self.flavor == "numarray":
52
if str(self.type) == "CharType":
58
if self.type == "CharType":
59
atom = StringAtom(shape=self.shape, length=self.length,
62
atom = Atom(dtype=self.type, shape=self.shape, flavor=flavor)
63
title = self.__class__.__name__
64
filters = Filters(complevel = self.compress,
65
complib = self.complib,
66
shuffle = self.shuffle,
67
fletcher32 = self.fletcher32)
68
earray = self.fileh.createEArray(group, 'earray1', atom, title,
73
self.rowshape = list(earray.shape)
74
self.objsize = self.length
75
for i in self.rowshape:
78
self.extdim = earray.extdim
79
self.objsize *= self.chunksize
80
self.rowshape[earray.extdim] = self.chunksize
81
if self.flavor == "numarray":
82
if str(self.type) == "CharType":
83
object = strings.array("a"*self.objsize, shape=self.rowshape,
84
itemsize=earray.itemsize)
86
object = arange(self.objsize, shape=self.rowshape,
88
else: # Numeric flavor
89
object = Numeric.arange(self.objsize,
90
typecode=typecode[earray.type])
91
object = Numeric.reshape(object, self.rowshape)
93
if self.flavor == "numarray":
94
print "Object to append -->", object.info()
96
print "Object to append -->", repr(object)
97
for i in range(self.nappends):
98
if str(self.type) == "CharType":
100
elif self.flavor == "numarray":
101
earray.append(object*i)
104
# For Numeric arrays, we still have to undo the type upgrade
105
earray.append(object.astype(typecode[earray.type]))
111
#----------------------------------------
113
def test01_iterEArray(self):
114
"""Checking enlargeable array iterator"""
116
rootgroup = self.rootgroup
118
print '\n', '-=' * 30
119
print "Running %s.test01_iterEArray..." % self.__class__.__name__
121
# Create an instance of an HDF5 Table
123
self.fileh = openFile(self.file, "r")
124
earray = self.fileh.getNode("/earray1")
126
# Choose a small value for buffer size
127
earray._v_maxTuples = 3
129
print "EArray descr:", repr(earray)
130
print "shape of read array ==>", earray.shape
131
print "reopening?:", self.reopen
133
# Build the array to do comparisons
134
if self.flavor == "numarray":
135
if str(self.type) == "CharType":
136
object_ = strings.array("a"*self.objsize, shape=self.rowshape,
137
itemsize=earray.itemsize)
139
object_ = arange(self.objsize, shape=self.rowshape,
141
object_.swapaxes(earray.extdim, 0)
143
object_ = Numeric.arange(self.objsize,
144
typecode=typecode[earray.type])
145
object_ = Numeric.reshape(object_, self.rowshape)
146
object_ = Numeric.swapaxes(object_, earray.extdim, 0)
150
chunk = int(earray.nrow % self.chunksize)
152
if str(self.type) == "CharType":
155
object__ = object_ * (earray.nrow / self.chunksize)
156
if self.flavor == "Numeric":
157
object__ = object__.astype(typecode[earray.type])
158
object = object__[chunk]
159
# The next adds much more verbosity
161
print "number of row ==>", earray.nrow
162
if hasattr(object, "shape"):
163
print "shape should look as:", object.shape
164
print "row in earray ==>", repr(row)
165
print "Should look like ==>", repr(object)
167
assert self.nappends*self.chunksize == earray.nrows
168
assert allequal(row, object, self.flavor)
169
if hasattr(row, "shape"):
170
assert len(row.shape) == len(self.shape) - 1
173
assert len(self.shape) == 1
176
if self.compress <> earray.filters.complevel and verbose:
177
print "Error in compress. Class:", self.__class__.__name__
178
print "self, earray:", self.compress, earray.filters.complevel
179
tinfo = whichLibVersion(self.complib)
181
self.complib = "zlib"
182
assert earray.filters.complib == self.complib
183
assert earray.filters.complevel == self.compress
184
if self.shuffle <> earray.filters.shuffle and verbose:
185
print "Error in shuffle. Class:", self.__class__.__name__
186
print "self, earray:", self.shuffle, earray.filters.shuffle
187
assert self.shuffle == earray.filters.shuffle
188
if self.fletcher32 <> earray.filters.fletcher32 and verbose:
189
print "Error in fletcher32. Class:", self.__class__.__name__
190
print "self, earray:", self.fletcher32, earray.filters.fletcher32
191
assert self.fletcher32 == earray.filters.fletcher32
193
def test02_sssEArray(self):
194
"""Checking enlargeable array iterator with (start, stop, step)"""
196
rootgroup = self.rootgroup
198
print '\n', '-=' * 30
199
print "Running %s.test02_sssEArray..." % self.__class__.__name__
201
# Create an instance of an HDF5 Table
203
self.fileh = openFile(self.file, "r")
204
earray = self.fileh.getNode("/earray1")
206
# Choose a small value for buffer size
207
earray._v_maxTuples = 3
209
print "EArray descr:", repr(earray)
210
print "shape of read array ==>", earray.shape
211
print "reopening?:", self.reopen
213
# Build the array to do comparisons
214
if self.flavor == "numarray":
215
if str(self.type) == "CharType":
216
object_ = strings.array("a"*self.objsize, shape=self.rowshape,
217
itemsize=earray.itemsize)
219
object_ = arange(self.objsize, shape=self.rowshape,
221
object_.swapaxes(earray.extdim, 0)
223
object_ = Numeric.arange(self.objsize,
224
typecode=typecode[earray.type])
225
object_ = Numeric.reshape(object_, self.rowshape)
226
object_ = Numeric.swapaxes(object_, earray.extdim, 0)
229
for row in earray.iterrows(start=self.start, stop=self.stop, step=self.step):
230
if self.chunksize == 1:
233
index = int(earray.nrow % self.chunksize)
234
if str(self.type) == "CharType":
237
object__ = object_ * (earray.nrow / self.chunksize)
238
if self.flavor == "Numeric":
239
object__ = object__.astype(typecode[earray.type])
240
object = object__[index]
241
# The next adds much more verbosity
243
print "number of row ==>", earray.nrow
244
if hasattr(object, "shape"):
245
print "shape should look as:", object.shape
246
print "row in earray ==>", repr(row)
247
print "Should look like ==>", repr(object)
249
assert self.nappends*self.chunksize == earray.nrows
250
assert allequal(row, object, self.flavor)
251
if hasattr(row, "shape"):
252
assert len(row.shape) == len(self.shape) - 1
255
assert len(self.shape) == 1
257
def test03_readEArray(self):
258
"""Checking read() of enlargeable arrays"""
260
rootgroup = self.rootgroup
262
print '\n', '-=' * 30
263
print "Running %s.test03_readEArray..." % self.__class__.__name__
265
# Create an instance of an HDF5 Table
267
self.fileh = openFile(self.file, "r")
268
earray = self.fileh.getNode("/earray1")
270
# Choose a small value for buffer size
271
earray._v_maxTuples = 3
273
print "EArray descr:", repr(earray)
274
print "shape of read array ==>", earray.shape
275
print "reopening?:", self.reopen
277
# Build the array to do comparisons
278
if self.flavor == "numarray":
279
if str(self.type) == "CharType":
280
object_ = strings.array("a"*self.objsize, shape=self.rowshape,
281
itemsize=earray.itemsize)
283
object_ = arange(self.objsize, shape=self.rowshape,
285
object_.swapaxes(earray.extdim, 0)
287
object_ = Numeric.arange(self.objsize,
288
typecode=typecode[earray.type])
289
object_ = Numeric.reshape(object_, self.rowshape)
290
object_ = Numeric.swapaxes(object_, earray.extdim, 0)
292
rowshape = self.rowshape
293
rowshape[self.extdim] *= self.nappends
294
if self.flavor == "numarray":
295
if str(self.type) == "CharType":
296
object__ = strings.array(None, shape=rowshape,
297
itemsize=earray.itemsize)
299
object__ = array(None, shape = rowshape, type=self.type)
300
object__.swapaxes(0, self.extdim)
302
object__ = Numeric.zeros(self.rowshape, typecode[earray.type])
303
object__ = Numeric.swapaxes(object__, earray.extdim, 0)
305
for i in range(self.nappends):
306
j = i * self.chunksize
307
if str(self.type) == "CharType":
308
object__[j:j+self.chunksize] = object_
310
if self.flavor == "numarray":
311
object__[j:j+self.chunksize] = object_ * i
313
object__[j:j+self.chunksize] = (object_ * i).astype(typecode[earray.type])
316
# stop == None means read only the element designed by start
317
# (in read() contexts)
318
if self.stop == None:
319
if self.start == -1: # corner case
322
stop = self.start + 1
323
# Protection against number of elements less than existing
324
#if rowshape[self.extdim] < self.stop or self.stop == 0:
325
if rowshape[self.extdim] < stop:
326
# self.stop == 0 means last row only in read()
327
# and not in [::] slicing notation
328
stop = rowshape[self.extdim]
329
# do a copy() in order to ensure that len(object._data)
330
# actually do a measure of its length
331
object = object__[self.start:stop:self.step].copy()
332
# Swap the axes again to have normal ordering
333
if self.flavor == "numarray":
334
object.swapaxes(0, self.extdim)
336
object = Numeric.swapaxes(object, 0, self.extdim)
338
if self.flavor == "numarray":
339
object = array(None, shape = self.shape, type=self.type)
341
object = Numeric.zeros(self.shape, typecode[self.type])
345
row = earray.read(self.start,self.stop,self.step)
347
if self.flavor == "numarray":
348
row = array(None, shape = self.shape, type=self.type)
350
row = Numeric.zeros(self.shape, typecode[self.type])
353
if hasattr(object, "shape"):
354
print "shape should look as:", object.shape
355
print "Object read ==>", repr(row)
356
print "Should look like ==>", repr(object)
358
assert self.nappends*self.chunksize == earray.nrows
359
assert allequal(row, object, self.flavor)
360
if hasattr(row, "shape"):
361
assert len(row.shape) == len(self.shape)
364
assert len(self.shape) == 1
366
def test04_getitemEArray(self):
367
"""Checking enlargeable array __getitem__ special method"""
369
rootgroup = self.rootgroup
371
print '\n', '-=' * 30
372
print "Running %s.test04_getitemEArray..." % self.__class__.__name__
374
if not hasattr(self, "slices"):
375
# If there is not a slices attribute, create it
376
self.slices = (slice(self.start, self.stop, self.step),)
378
# Create an instance of an HDF5 Table
380
self.fileh = openFile(self.file, "r")
381
earray = self.fileh.getNode("/earray1")
383
# Choose a small value for buffer size
384
#earray._v_maxTuples = 3 # this does not really changes the chunksize
386
print "EArray descr:", repr(earray)
387
print "shape of read array ==>", earray.shape
388
print "reopening?:", self.reopen
390
# Build the array to do comparisons
391
if str(self.type) == "CharType":
392
object_ = strings.array("a"*self.objsize, shape=self.rowshape,
393
itemsize=earray.itemsize)
395
object_ = arange(self.objsize, shape=self.rowshape,
397
object_.swapaxes(earray.extdim, 0)
399
rowshape = self.rowshape
400
rowshape[self.extdim] *= self.nappends
401
if str(self.type) == "CharType":
402
object__ = strings.array(None, shape=rowshape,
403
itemsize=earray.itemsize)
405
object__ = array(None, shape = rowshape, type=self.type)
406
object__.swapaxes(0, self.extdim)
408
for i in range(self.nappends):
409
j = i * self.chunksize
410
if str(self.type) == "CharType":
411
object__[j:j+self.chunksize] = object_
413
object__[j:j+self.chunksize] = object_ * i
417
# Swap the axes again to have normal ordering
418
object__.swapaxes(0, self.extdim)
419
# do a copy() in order to ensure that len(object._data)
420
# actually do a measure of its length
421
object = object__.__getitem__(self.slices).copy()
423
object = array(None, shape = self.shape, type=self.type)
425
if self.flavor == "Numeric":
426
# Convert the object to Numeric
427
object = Numeric.array(object, typecode=typecode[self.type])
430
row = earray.__getitem__(self.slices)
432
row = earray.__getitem__(self.slices)
435
if self.flavor == "numarray":
436
row = array(None, shape = self.shape, type=self.type)
438
row = Numeric.zeros(self.shape, typecode[self.type])
441
print "Object read:\n", repr(row) #, row.info()
442
print "Should look like:\n", repr(object) #, row.info()
443
if hasattr(object, "shape"):
444
print "Original object shape:", self.shape
445
print "Shape read:", row.shape
446
print "shape should look as:", object.shape
448
assert self.nappends*self.chunksize == earray.nrows
449
assert allequal(row, object, self.flavor)
450
if not hasattr(row, "shape"):
452
assert len(self.shape) == 1
455
def test05_setitemEArray(self):
456
"""Checking enlargeable array __setitem__ special method"""
458
rootgroup = self.rootgroup
459
if self.__class__.__name__ == "Ellipsis6EArrayTestCase":
460
# We have a problem with test design here, but I think
461
# it is not worth the effort to solve it
465
print '\n', '-=' * 30
466
print "Running %s.test05_setitemEArray..." % self.__class__.__name__
468
if not hasattr(self, "slices"):
469
# If there is not a slices attribute, create it
470
self.slices = (slice(self.start, self.stop, self.step),)
472
# Create an instance of an HDF5 Table
474
self.fileh = openFile(self.file, "a")
475
earray = self.fileh.getNode("/earray1")
477
# Choose a small value for buffer size
478
#earray._v_maxTuples = 3 # this does not really changes the chunksize
480
print "EArray descr:", repr(earray)
481
print "shape of read array ==>", earray.shape
482
print "reopening?:", self.reopen
484
# Build the array to do comparisons
485
if str(self.type) == "CharType":
486
object_ = strings.array("a"*self.objsize, shape=self.rowshape,
487
itemsize=earray.itemsize)
489
object_ = arange(self.objsize, shape=self.rowshape,
491
object_.swapaxes(earray.extdim, 0)
493
rowshape = self.rowshape
494
rowshape[self.extdim] *= self.nappends
495
if str(self.type) == "CharType":
496
object__ = strings.array(None, shape=rowshape,
497
itemsize=earray.itemsize)
499
object__ = array(None, shape = rowshape, type=self.type)
500
object__.swapaxes(0, self.extdim)
502
for i in range(self.nappends):
503
j = i * self.chunksize
504
if str(self.type) == "CharType":
505
object__[j:j+self.chunksize] = object_
507
object__[j:j+self.chunksize] = object_ * i
509
#earray[j:j+self.chunksize] = object_ * i
510
#earray[self.slices] = 1
514
# Swap the axes again to have normal ordering
515
object__.swapaxes(0, self.extdim)
516
# do a copy() in order to ensure that len(object._data)
517
# actually do a measure of its length
518
object = object__.__getitem__(self.slices).copy()
520
object = array(None, shape = self.shape, type=self.type)
522
if self.flavor == "Numeric":
523
# Convert the object to Numeric
524
object = Numeric.array(object, typecode=typecode[self.type])
526
if str(self.type) == "CharType":
527
if hasattr(self, "wslice"):
528
object[self.wslize] = object[self.wslice].pad("xXx")
529
earray[self.wslice] = earray[self.wslice].pad("xXx")
530
elif sum(object[self.slices].shape) <> 0 :
531
object[:] = object.pad("xXx")
532
if object.size() > 0:
533
earray[self.slices] = object
535
if hasattr(self, "wslice"):
536
object[self.wslice] = object[self.wslice] * 2 + 3
537
earray[self.wslice] = earray[self.wslice] * 2 + 3
538
elif sum(object[self.slices].shape) <> 0:
539
object = object * 2 + 3
540
if reduce(lambda x,y:x*y, object.shape) > 0:
541
earray[self.slices] = earray[self.slices] * 2 + 3
543
row = earray.__getitem__(self.slices)
545
row = earray.__getitem__(self.slices)
548
if self.flavor == "numarray":
549
row = array(None, shape = self.shape, type=self.type)
551
row = Numeric.zeros(self.shape, typecode[self.type])
554
print "Object read:\n", repr(row) #, row.info()
555
print "Should look like:\n", repr(object) #, row.info()
556
if hasattr(object, "shape"):
557
print "Original object shape:", self.shape
558
print "Shape read:", row.shape
559
print "shape should look as:", object.shape
561
assert self.nappends*self.chunksize == earray.nrows
562
assert allequal(row, object, self.flavor)
563
if not hasattr(row, "shape"):
565
assert len(self.shape) == 1
568
class BasicWriteTestCase(BasicTestCase):
574
#wslice = slice(1,nappends,2)
575
wslice = 1 # single element case
577
class BasicWrite2TestCase(BasicTestCase):
583
wslice = slice(chunksize-2,nappends,2) # range of elements
584
reopen = 0 # This case does not reopen files
586
class EmptyEArrayTestCase(BasicTestCase):
595
class EmptyEArray2TestCase(BasicTestCase):
603
reopen = 0 # This case does not reopen files
605
class SlicesEArrayTestCase(BasicTestCase):
612
slices = (slice(1,2,1), slice(1,3,1))
614
class EllipsisEArrayTestCase(BasicTestCase):
619
#slices = (slice(1,2,1), Ellipsis)
620
slices = (Ellipsis, slice(1,2,1))
622
class Slices2EArrayTestCase(BasicTestCase):
629
slices = (slice(1,2,1), slice(None, None, None), slice(1,4,2))
631
class Ellipsis2EArrayTestCase(BasicTestCase):
636
slices = (slice(1,2,1), Ellipsis, slice(1,4,2))
638
class Slices3EArrayTestCase(BasicTestCase):
639
compress = 1 # To show the chunks id DEBUG is on
645
slices = (slice(1, 2, 1), slice(0, None, None), slice(1,4,2)) # Don't work
646
#slices = (slice(None, None, None), slice(0, None, None), slice(1,4,1)) # W
647
#slices = (slice(None, None, None), slice(None, None, None), slice(1,4,2)) # N
648
#slices = (slice(1,2,1), slice(None, None, None), slice(1,4,2)) # N
649
# Disable the failing test temporarily with a working test case
650
slices = (slice(1,2,1), slice(1, 4, None), slice(1,4,2)) # Y
651
#slices = (slice(1,2,1), slice(0, 4, None), slice(1,4,1)) # Y
652
slices = (slice(1,2,1), slice(0, 4, None), slice(1,4,2)) # N
653
#slices = (slice(1,2,1), slice(0, 4, None), slice(1,4,2), slice(0,100,1)) # N
655
class Slices4EArrayTestCase(BasicTestCase):
657
shape = (2, 3, 4, 0, 5, 6)
660
slices = (slice(1, 2, 1), slice(0, None, None), slice(1,4,2),
661
slice(0,4,2), slice(3,5,2), slice(2,7,1))
663
class Ellipsis3EArrayTestCase(BasicTestCase):
668
slices = (Ellipsis, slice(0, 4, None), slice(1,4,2))
669
slices = (slice(1,2,1), slice(0, 4, None), slice(1,4,2), Ellipsis)
671
class Ellipsis4EArrayTestCase(BasicTestCase):
676
slices = (Ellipsis, slice(0, 4, None), slice(1,4,2))
677
slices = (slice(1,2,1), Ellipsis, slice(1,4,2))
679
class Ellipsis5EArrayTestCase(BasicTestCase):
684
slices = (slice(1,2,1), slice(0, 4, None), Ellipsis)
686
class Ellipsis6EArrayTestCase(BasicTestCase):
691
# The next slices gives problems with setting values (test05)
692
# This is a problem on the test design, not the Array.__setitem__
694
slices = (slice(1,2,1), slice(0, 4, None), 2, Ellipsis)
696
class Ellipsis7EArrayTestCase(BasicTestCase):
701
slices = (slice(1,2,1), slice(0, 4, None), slice(2,3), Ellipsis)
703
class MD3WriteTestCase(BasicTestCase):
709
class MD5WriteTestCase(BasicTestCase):
711
shape = (2, 0, 3, 4, 5) # ok
712
#shape = (1, 1, 0, 1) # Minimum shape that shows problems with HDF5 1.6.1
713
#shape = (2, 3, 0, 4, 5) # Floating point exception (HDF5 1.6.1)
714
#shape = (2, 3, 3, 0, 5, 6) # Segmentation fault (HDF5 1.6.1)
721
class MD6WriteTestCase(BasicTestCase):
723
shape = (2, 3, 3, 0, 5, 6)
730
class MD6WriteTestCase__(BasicTestCase):
739
class MD7WriteTestCase(BasicTestCase):
741
shape = (2, 3, 3, 4, 5, 0, 3)
748
class MD10WriteTestCase(BasicTestCase):
750
shape = (1, 2, 3, 4, 5, 5, 4, 3, 2, 0)
757
class ZlibComprTestCase(BasicTestCase):
761
#stop = 0 # means last row
762
stop = None # means last row from 0.8 on
765
class ZlibShuffleTestCase(BasicTestCase):
769
# case start < stop , i.e. no rows read
774
class LZOComprTestCase(BasicTestCase):
783
class LZOShuffleTestCase(BasicTestCase):
793
class UCLComprTestCase(BasicTestCase):
802
class UCLShuffleTestCase(BasicTestCase):
812
class Fletcher32TestCase(BasicTestCase):
821
class AllFiltersTestCase(BasicTestCase):
837
class FloatTypeTestCase(BasicTestCase):
846
class ComplexTypeTestCase(BasicTestCase):
855
class CharTypeTestCase(BasicTestCase):
865
slices = (slice(0,1),slice(1,2))
867
class CharType2TestCase(BasicTestCase):
878
class CharTypeComprTestCase(BasicTestCase):
882
#shape = (20,0,10,20)
884
#shuffle = 1 # this shouldn't do nothing on chars
891
class Numeric1TestCase(BasicTestCase):
892
# Setting flavor to Numeric here gives some problems due,
893
# most probably to test implementation, not library code
905
class Numeric2TestCase(BasicTestCase):
907
# type = Float32 gives some problems on tests. It is *not* a
908
# problem with Array.__setitem__(), just with test design
920
class NumericComprTestCase(BasicTestCase):
933
# It remains a test of Numeric char types, but the code is getting too messy
935
class OffsetStrideTestCase(unittest.TestCase):
938
complib = "zlib" # Default compression library
942
# Create an instance of an HDF5 Table
943
self.file = tempfile.mktemp(".h5")
944
self.fileh = openFile(self.file, self.mode)
945
self.rootgroup = self.fileh.root
951
#----------------------------------------
953
def test01a_String(self):
954
"""Checking earray with offseted numarray strings appends"""
956
root = self.rootgroup
958
print '\n', '-=' * 30
959
print "Running %s.test01a_StringAtom..." % self.__class__.__name__
961
# Create an string atom
962
earray = self.fileh.createEArray(root, 'strings',
966
a=strings.array([[["a","b"],["123", "45"],["45", "123"]]], itemsize=3)
967
earray.append(a[:,1:])
968
a=strings.array([[["s", "a"],["ab", "f"],["s", "abc"],["abc", "f"]]])
969
earray.append(a[:,2:])
974
print "Object read:", row
975
print "Nrows in", earray._v_pathname, ":", earray.nrows
976
print "Second row in earray ==>", row[1].tolist()
978
assert earray.nrows == 2
979
assert row[0].tolist() == [["123", "45"],["45", "123"]]
980
assert row[1].tolist() == [["s", "abc"],["abc", "f"]]
981
assert len(row[0]) == 2
982
assert len(row[1]) == 2
984
def test01b_String(self):
985
"""Checking earray with strided numarray strings appends"""
987
root = self.rootgroup
989
print '\n', '-=' * 30
990
print "Running %s.test01b_StringAtom..." % self.__class__.__name__
992
# Create an string atom
993
earray = self.fileh.createEArray(root, 'strings',
997
a=strings.array([[["a","b"],["123", "45"],["45", "123"]]], itemsize=3)
998
earray.append(a[:,::2])
999
a=strings.array([[["s", "a"],["ab", "f"],["s", "abc"],["abc", "f"]]])
1000
earray.append(a[:,::2])
1002
# Read all the rows:
1005
print "Object read:", row
1006
print "Nrows in", earray._v_pathname, ":", earray.nrows
1007
print "Second row in earray ==>", row[1].tolist()
1009
assert earray.nrows == 2
1010
assert row[0].tolist() == [["a","b"],["45", "123"]]
1011
assert row[1].tolist() == [["s", "a"],["s", "abc"]]
1012
assert len(row[0]) == 2
1013
assert len(row[1]) == 2
1015
def test02a_int(self):
1016
"""Checking earray with offseted numarray ints appends"""
1018
root = self.rootgroup
1020
print '\n', '-=' * 30
1021
print "Running %s.test02a_int..." % self.__class__.__name__
1023
# Create an string atom
1024
earray = self.fileh.createEArray(root, 'EAtom',
1025
Int32Atom(shape=(0,3)),
1027
a=array([(0,0,0), (1,0,3), (1,1,1), (0,0,0)], type=Int32)
1028
earray.append(a[2:]) # Create an offset
1029
a=array([(1,1,1), (-1,0,0)], type=Int32)
1030
earray.append(a[1:]) # Create an offset
1032
# Read all the rows:
1035
print "Object read:", row
1036
print "Nrows in", earray._v_pathname, ":", earray.nrows
1037
print "Third row in vlarray ==>", row[2]
1039
assert earray.nrows == 3
1040
assert allequal(row[0], array([1,1,1], type=Int32))
1041
assert allequal(row[1], array([0,0,0], type=Int32))
1042
assert allequal(row[2], array([-1,0,0], type=Int32))
1044
def test02b_int(self):
1045
"""Checking earray with strided numarray ints appends"""
1047
root = self.rootgroup
1049
print '\n', '-=' * 30
1050
print "Running %s.test02b_int..." % self.__class__.__name__
1052
# Create an string atom
1053
earray = self.fileh.createEArray(root, 'EAtom',
1054
Int32Atom(shape=(0,3)),
1056
a=array([(0,0,0), (1,0,3), (1,1,1), (3,3,3)], type=Int32)
1057
earray.append(a[::3]) # Create an offset
1058
a=array([(1,1,1), (-1,0,0)], type=Int32)
1059
earray.append(a[::2]) # Create an offset
1061
# Read all the rows:
1064
print "Object read:", row
1065
print "Nrows in", earray._v_pathname, ":", earray.nrows
1066
print "Third row in vlarray ==>", row[2]
1068
assert earray.nrows == 3
1069
assert allequal(row[0], array([0,0,0], type=Int32))
1070
assert allequal(row[1], array([3,3,3], type=Int32))
1071
assert allequal(row[2], array([1,1,1], type=Int32))
1073
class CopyTestCase(unittest.TestCase):
1075
def test01_copy(self):
1076
"""Checking EArray.copy() method """
1079
print '\n', '-=' * 30
1080
print "Running %s.test01_copy..." % self.__class__.__name__
1082
# Create an instance of an HDF5 Table
1083
file = tempfile.mktemp(".h5")
1084
fileh = openFile(file, "w")
1087
arr = Atom(shape=(0, 2), dtype=Int16)
1088
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1089
array1.append(array([[456, 2],[3, 457]], type=Int16))
1093
print "(closing file version)"
1095
fileh = openFile(file, mode = "a")
1096
array1 = fileh.root.array1
1098
# Copy it to another location
1099
array2, size = array1.copy('/', 'array2')
1103
print "(closing file version)"
1105
fileh = openFile(file, mode = "r")
1106
array1 = fileh.root.array1
1107
array2 = fileh.root.array2
1110
print "array1-->", array1.read()
1111
print "array2-->", array2.read()
1112
#print "dirs-->", dir(array1), dir(array2)
1113
print "attrs array1-->", repr(array1.attrs)
1114
print "attrs array2-->", repr(array2.attrs)
1116
# Check that all the elements are equal
1117
assert allequal(array1.read(), array2.read())
1119
# Assert other properties in array
1120
assert array1.nrows == array2.nrows
1121
assert array1.shape == array2.shape
1122
assert array1.extdim == array2.extdim
1123
assert array1.flavor == array2.flavor
1124
assert array1.type == array2.type
1125
assert array1.itemsize == array2.itemsize
1126
assert array1.title == array2.title
1127
assert str(array1.atom) == str(array2.atom)
1133
def test02_copy(self):
1134
"""Checking EArray.copy() method (where specified)"""
1137
print '\n', '-=' * 30
1138
print "Running %s.test02_copy..." % self.__class__.__name__
1140
# Create an instance of an HDF5 Table
1141
file = tempfile.mktemp(".h5")
1142
fileh = openFile(file, "w")
1145
arr = Atom(shape=(0, 2), dtype=Int16)
1146
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1147
array1.append(array([[456, 2],[3, 457]], type=Int16))
1151
print "(closing file version)"
1153
fileh = openFile(file, mode = "a")
1154
array1 = fileh.root.array1
1156
# Copy to another location
1157
group1 = fileh.createGroup("/", "group1")
1158
array2, size = array1.copy(group1, 'array2')
1162
print "(closing file version)"
1164
fileh = openFile(file, mode = "r")
1165
array1 = fileh.root.array1
1166
array2 = fileh.root.group1.array2
1169
print "array1-->", array1.read()
1170
print "array2-->", array2.read()
1171
#print "dirs-->", dir(array1), dir(array2)
1172
print "attrs array1-->", repr(array1.attrs)
1173
print "attrs array2-->", repr(array2.attrs)
1175
# Check that all the elements are equal
1176
assert allequal(array1.read(), array2.read())
1178
# Assert other properties in array
1179
assert array1.nrows == array2.nrows
1180
assert array1.shape == array2.shape
1181
assert array1.extdim == array2.extdim
1182
assert array1.flavor == array2.flavor
1183
assert array1.type == array2.type
1184
assert array1.itemsize == array2.itemsize
1185
assert array1.title == array2.title
1186
assert str(array1.atom) == str(array2.atom)
1192
def test03_copy(self):
1193
"""Checking EArray.copy() method (Numeric flavor)"""
1196
print '\n', '-=' * 30
1197
print "Running %s.test03_copy..." % self.__class__.__name__
1199
# Create an instance of an HDF5 Table
1200
file = tempfile.mktemp(".h5")
1201
fileh = openFile(file, "w")
1204
arr = Atom(shape=(0, 2), dtype=Int16, flavor="Numeric")
1206
arr = Atom(shape=(0, 2), dtype=Int16)
1208
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1209
array1.append(array([[456, 2],[3, 457]], type=Int16))
1213
print "(closing file version)"
1215
fileh = openFile(file, mode = "a")
1216
array1 = fileh.root.array1
1218
# Copy to another location
1219
array2, size = array1.copy('/', 'array2')
1223
print "(closing file version)"
1225
fileh = openFile(file, mode = "r")
1226
array1 = fileh.root.array1
1227
array2 = fileh.root.array2
1230
print "attrs array1-->", repr(array1.attrs)
1231
print "attrs array2-->", repr(array2.attrs)
1233
# Assert other properties in array
1234
assert array1.nrows == array2.nrows
1235
assert array1.shape == array2.shape
1236
assert array1.extdim == array2.extdim
1237
assert array1.flavor == array2.flavor # Very important here!
1238
assert array1.type == array2.type
1239
assert array1.itemsize == array2.itemsize
1240
assert array1.title == array2.title
1241
assert str(array1.atom) == str(array2.atom)
1247
def test03b_copy(self):
1248
"""Checking EArray.copy() method (Tuple flavor)"""
1251
print '\n', '-=' * 30
1252
print "Running %s.test03b_copy..." % self.__class__.__name__
1254
# Create an instance of an HDF5 Table
1255
file = tempfile.mktemp(".h5")
1256
fileh = openFile(file, "w")
1258
arr = Atom(shape=(0, 2), dtype=Int16, flavor="Tuple")
1259
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1260
array1.append(((456, 2),(3, 457)))
1264
print "(closing file version)"
1266
fileh = openFile(file, mode = "a")
1267
array1 = fileh.root.array1
1269
# Copy to another location
1270
array2, size = array1.copy('/', 'array2')
1274
print "(closing file version)"
1276
fileh = openFile(file, mode = "r")
1277
array1 = fileh.root.array1
1278
array2 = fileh.root.array2
1281
print "attrs array1-->", repr(array1.attrs)
1282
print "attrs array2-->", repr(array2.attrs)
1284
# Check that all elements are equal
1285
assert array1.read() == array2.read()
1286
# Assert other properties in array
1287
assert array1.nrows == array2.nrows
1288
assert array1.shape == array2.shape
1289
assert array1.extdim == array2.extdim
1290
assert array1.flavor == array2.flavor # Very important here!
1291
assert array1.type == array2.type
1292
assert array1.itemsize == array2.itemsize
1293
assert array1.title == array2.title
1294
assert str(array1.atom) == str(array2.atom)
1300
def test03c_copy(self):
1301
"""Checking EArray.copy() method (List flavor)"""
1304
print '\n', '-=' * 30
1305
print "Running %s.test03c_copy..." % self.__class__.__name__
1307
# Create an instance of an HDF5 Table
1308
file = tempfile.mktemp(".h5")
1309
fileh = openFile(file, "w")
1311
arr = Atom(shape=(0, 2), dtype=Int16, flavor="List")
1312
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1313
array1.append([[456, 2],[3, 457]])
1317
print "(closing file version)"
1319
fileh = openFile(file, mode = "a")
1320
array1 = fileh.root.array1
1322
# Copy to another location
1323
array2, size = array1.copy('/', 'array2')
1327
print "(closing file version)"
1329
fileh = openFile(file, mode = "r")
1330
array1 = fileh.root.array1
1331
array2 = fileh.root.array2
1334
print "attrs array1-->", repr(array1.attrs)
1335
print "attrs array2-->", repr(array2.attrs)
1337
# Check that all elements are equal
1338
assert array1.read() == array2.read()
1339
# Assert other properties in array
1340
assert array1.nrows == array2.nrows
1341
assert array1.shape == array2.shape
1342
assert array1.extdim == array2.extdim
1343
assert array1.flavor == array2.flavor # Very important here!
1344
assert array1.type == array2.type
1345
assert array1.itemsize == array2.itemsize
1346
assert array1.title == array2.title
1347
assert str(array1.atom) == str(array2.atom)
1353
def test03d_copy(self):
1354
"""Checking EArray.copy() method (String flavor)"""
1357
print '\n', '-=' * 30
1358
print "Running %s.test03d_copy..." % self.__class__.__name__
1360
# Create an instance of an HDF5 Table
1361
file = tempfile.mktemp(".h5")
1362
fileh = openFile(file, "w")
1364
arr = StringAtom(shape=(0, 2), length=4, flavor="String")
1365
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1366
array1.append([["456", "2"],["3", "457"]])
1370
print "(closing file version)"
1372
fileh = openFile(file, mode = "a")
1373
array1 = fileh.root.array1
1375
# Copy to another location
1376
array2, size = array1.copy('/', 'array2')
1380
print "(closing file version)"
1382
fileh = openFile(file, mode = "r")
1383
array1 = fileh.root.array1
1384
array2 = fileh.root.array2
1387
print "attrs array1-->", repr(array1.attrs)
1388
print "attrs array2-->", repr(array2.attrs)
1390
# Check that all elements are equal
1391
assert array1.read() == array2.read()
1393
# Assert other properties in array
1394
assert array1.nrows == array2.nrows
1395
assert array1.shape == array2.shape
1396
assert array1.extdim == array2.extdim
1397
assert array1.flavor == array2.flavor # Very important here!
1398
assert array1.type == array2.type
1399
assert array1.itemsize == array2.itemsize
1400
assert array1.title == array2.title
1401
assert str(array1.atom) == str(array2.atom)
1407
def test03e_copy(self):
1408
"""Checking EArray.copy() method (CharArray flavor)"""
1411
print '\n', '-=' * 30
1412
print "Running %s.test03e_copy..." % self.__class__.__name__
1414
# Create an instance of an HDF5 Table
1415
file = tempfile.mktemp(".h5")
1416
fileh = openFile(file, "w")
1418
arr = StringAtom(shape=(0, 2), length=4, flavor="CharArray")
1419
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1420
array1.append(strings.array([["456", "2"],["3", "457"]], itemsize=4))
1424
print "(closing file version)"
1426
fileh = openFile(file, mode = "a")
1427
array1 = fileh.root.array1
1429
# Copy to another location
1430
array2, size = array1.copy('/', 'array2')
1434
print "(closing file version)"
1436
fileh = openFile(file, mode = "r")
1437
array1 = fileh.root.array1
1438
array2 = fileh.root.array2
1441
print "attrs array1-->", repr(array1.attrs)
1442
print "attrs array2-->", repr(array2.attrs)
1444
# Check that all elements are equal
1445
assert allequal(array1.read(), array2.read())
1446
# Assert other properties in array
1447
assert array1.nrows == array2.nrows
1448
assert array1.shape == array2.shape
1449
assert array1.extdim == array2.extdim
1450
assert array1.flavor == array2.flavor # Very important here!
1451
assert array1.type == array2.type
1452
assert array1.itemsize == array2.itemsize
1453
assert array1.title == array2.title
1454
assert str(array1.atom) == str(array2.atom)
1460
def test04_copy(self):
1461
"""Checking EArray.copy() method (checking title copying)"""
1464
print '\n', '-=' * 30
1465
print "Running %s.test04_copy..." % self.__class__.__name__
1467
# Create an instance of an HDF5 Table
1468
file = tempfile.mktemp(".h5")
1469
fileh = openFile(file, "w")
1472
atom=Int16Atom(shape=(0,2))
1473
array1 = fileh.createEArray(fileh.root, 'array1', atom, "title array1")
1474
array1.append(array([[456, 2],[3, 457]], type=Int16))
1475
# Append some user attrs
1476
array1.attrs.attr1 = "attr1"
1477
array1.attrs.attr2 = 2
1481
print "(closing file version)"
1483
fileh = openFile(file, mode = "a")
1484
array1 = fileh.root.array1
1486
# Copy it to another Array
1487
array2, size = array1.copy('/', 'array2', title="title array2")
1491
print "(closing file version)"
1493
fileh = openFile(file, mode = "r")
1494
array1 = fileh.root.array1
1495
array2 = fileh.root.array2
1497
# Assert user attributes
1499
print "title of destination array-->", array2.title
1500
array2.title == "title array2"
1506
def test05_copy(self):
1507
"""Checking EArray.copy() method (user attributes copied)"""
1510
print '\n', '-=' * 30
1511
print "Running %s.test05_copy..." % self.__class__.__name__
1513
# Create an instance of an HDF5 Table
1514
file = tempfile.mktemp(".h5")
1515
fileh = openFile(file, "w")
1518
atom=Int16Atom(shape=(0,2))
1519
array1 = fileh.createEArray(fileh.root, 'array1', atom, "title array1")
1520
array1.append(array([[456, 2],[3, 457]], type=Int16))
1521
# Append some user attrs
1522
array1.attrs.attr1 = "attr1"
1523
array1.attrs.attr2 = 2
1527
print "(closing file version)"
1529
fileh = openFile(file, mode = "a")
1530
array1 = fileh.root.array1
1532
# Copy it to another Array
1533
array2, size = array1.copy('/', 'array2', copyuserattrs=1)
1537
print "(closing file version)"
1539
fileh = openFile(file, mode = "r")
1540
array1 = fileh.root.array1
1541
array2 = fileh.root.array2
1544
print "attrs array1-->", repr(array1.attrs)
1545
print "attrs array2-->", repr(array2.attrs)
1547
# Assert user attributes
1548
array2.attrs.attr1 == "attr1"
1549
array2.attrs.attr2 == 2
1555
def test05b_copy(self):
1556
"""Checking EArray.copy() method (user attributes not copied)"""
1559
print '\n', '-=' * 30
1560
print "Running %s.test05b_copy..." % self.__class__.__name__
1562
# Create an instance of an HDF5 Table
1563
file = tempfile.mktemp(".h5")
1564
fileh = openFile(file, "w")
1567
atom=Int16Atom(shape=(0,2))
1568
array1 = fileh.createEArray(fileh.root, 'array1', atom, "title array1")
1569
array1.append(array([[456, 2],[3, 457]], type=Int16))
1570
# Append some user attrs
1571
array1.attrs.attr1 = "attr1"
1572
array1.attrs.attr2 = 2
1576
print "(closing file version)"
1578
fileh = openFile(file, mode = "a")
1579
array1 = fileh.root.array1
1581
# Copy it to another Array
1582
array2, size = array1.copy('/', 'array2', copyuserattrs=0)
1586
print "(closing file version)"
1588
fileh = openFile(file, mode = "r")
1589
array1 = fileh.root.array1
1590
array2 = fileh.root.array2
1593
print "attrs array1-->", repr(array1.attrs)
1594
print "attrs array2-->", repr(array2.attrs)
1596
# Assert user attributes
1597
hasattr(array2.attrs, "attr1") == 0
1598
hasattr(array2.attrs, "attr2") == 0
1605
class CloseCopyTestCase(CopyTestCase):
1608
class OpenCopyTestCase(CopyTestCase):
1611
class CopyIndexTestCase(unittest.TestCase):
1614
def test01_index(self):
1615
"""Checking EArray.copy() method with indexes"""
1618
print '\n', '-=' * 30
1619
print "Running %s.test01_index..." % self.__class__.__name__
1621
# Create an instance of an HDF5 Array
1622
file = tempfile.mktemp(".h5")
1623
fileh = openFile(file, "w")
1626
atom = Int32Atom(shape=(0,2))
1627
array1 = fileh.createEArray(fileh.root, 'array1', atom, "title array1")
1628
r = arange(200, type=Int32, shape=(100,2))
1631
# Select a different buffer size:
1632
array1._v_maxTuples = self.maxTuples
1634
# Copy to another array
1635
array2, size = array1.copy("/", 'array2',
1640
print "array1-->", array1.read()
1641
print "array2-->", array2.read()
1642
print "attrs array1-->", repr(array1.attrs)
1643
print "attrs array2-->", repr(array2.attrs)
1645
# Check that all the elements are equal
1646
r2 = r[self.start:self.stop:self.step]
1647
assert allequal(r2, array2.read())
1649
# Assert the number of rows in array
1651
print "nrows in array2-->", array2.nrows
1652
print "and it should be-->", r2.shape[0]
1653
assert r2.shape[0] == array2.nrows
1659
def test02_indexclosef(self):
1660
"""Checking EArray.copy() method with indexes (close file version)"""
1663
print '\n', '-=' * 30
1664
print "Running %s.test02_indexclosef..." % self.__class__.__name__
1666
# Create an instance of an HDF5 Array
1667
file = tempfile.mktemp(".h5")
1668
fileh = openFile(file, "w")
1671
atom = Int32Atom(shape=(0,2))
1672
array1 = fileh.createEArray(fileh.root, 'array1', atom, "title array1")
1673
r = arange(200, type=Int32, shape=(100,2))
1676
# Select a different buffer size:
1677
array1._v_maxTuples = self.maxTuples
1679
# Copy to another array
1680
array2, size = array1.copy("/", 'array2',
1684
# Close and reopen the file
1686
fileh = openFile(file, mode = "r")
1687
array1 = fileh.root.array1
1688
array2 = fileh.root.array2
1691
print "array1-->", array1.read()
1692
print "array2-->", array2.read()
1693
print "attrs array1-->", repr(array1.attrs)
1694
print "attrs array2-->", repr(array2.attrs)
1696
# Check that all the elements are equal
1697
r2 = r[self.start:self.stop:self.step]
1698
assert allequal(r2, array2.read())
1700
# Assert the number of rows in array
1702
print "nrows in array2-->", array2.nrows
1703
print "and it should be-->", r2.shape[0]
1704
assert r2.shape[0] == array2.nrows
1710
class CopyIndex1TestCase(CopyIndexTestCase):
1716
class CopyIndex2TestCase(CopyIndexTestCase):
1722
class CopyIndex3TestCase(CopyIndexTestCase):
1728
class CopyIndex4TestCase(CopyIndexTestCase):
1734
class CopyIndex5TestCase(CopyIndexTestCase):
1740
class CopyIndex6TestCase(CopyIndexTestCase):
1746
class CopyIndex7TestCase(CopyIndexTestCase):
1751
class CopyIndex8TestCase(CopyIndexTestCase):
1753
stop = -1 # Negative values means starting from the end
1756
class CopyIndex9TestCase(CopyIndexTestCase):
1761
class CopyIndex10TestCase(CopyIndexTestCase):
1767
class CopyIndex11TestCase(CopyIndexTestCase):
1772
class CopyIndex12TestCase(CopyIndexTestCase):
1773
start = -1 # Should point to the last element
1774
stop = None # None should mean the last element (including it)
1777
class TruncateTestCase(unittest.TestCase):
1779
def _test00_truncate(self):
1780
"""Checking EArray.truncate() method (truncating to 0 rows)"""
1783
print '\n', '-=' * 30
1784
print "Running %s.test00_truncate..." % self.__class__.__name__
1786
# Create an instance of an HDF5 Table
1787
file = tempfile.mktemp(".h5")
1788
fileh = openFile(file, "w")
1791
arr = Atom(shape=(0, 2), dtype=Int16)
1792
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1794
array1.append(array([[456, 2],[3, 457]], type=Int16))
1798
fileh = openFile(file, mode = "a")
1799
array1 = fileh.root.array1
1801
# Truncate to 0 elements
1802
size = array1.truncate(0)
1806
print "(closing file version)"
1808
fileh = openFile(file, mode = "r")
1809
array1 = fileh.root.array1
1812
print "array1-->", array1.read()
1813
print "size-->", size
1816
assert allequal(array1[:], array([], type=Int16, shape=(0,2)))
1818
def test01_truncate(self):
1819
"""Checking EArray.truncate() method (truncating to 1 rows)"""
1822
print '\n', '-=' * 30
1823
print "Running %s.test01_truncate..." % self.__class__.__name__
1825
# Create an instance of an HDF5 Table
1826
file = tempfile.mktemp(".h5")
1827
fileh = openFile(file, "w")
1830
arr = Atom(shape=(0, 2), dtype=Int16)
1831
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1833
array1.append(array([[456, 2],[3, 457]], type=Int16))
1837
fileh = openFile(file, mode = "a")
1838
array1 = fileh.root.array1
1840
# Truncate to 1 element
1841
size = array1.truncate(1)
1845
print "(closing file version)"
1847
fileh = openFile(file, mode = "r")
1848
array1 = fileh.root.array1
1851
print "array1-->", array1.read()
1852
print "size-->", size
1855
assert allequal(array1.read(), array([[456, 2]], type=Int16))
1857
def test02_truncate(self):
1858
"""Checking EArray.truncate() method (truncating to >= earray.nrows)"""
1861
print '\n', '-=' * 30
1862
print "Running %s.test02_truncate..." % self.__class__.__name__
1864
# Create an instance of an HDF5 Table
1865
file = tempfile.mktemp(".h5")
1866
fileh = openFile(file, "w")
1869
arr = Atom(shape=(0, 2), dtype=Int16)
1870
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1872
array1.append(array([[456, 2],[3, 457]], type=Int16))
1876
fileh = openFile(file, mode = "a")
1877
array1 = fileh.root.array1
1879
# Truncate to 2 elements
1880
size = array1.truncate(2)
1884
print "(closing file version)"
1886
fileh = openFile(file, mode = "r")
1887
array1 = fileh.root.array1
1890
print "array1-->", array1.read()
1891
print "size-->", size
1894
assert allequal(array1.read(), array([[456, 2],[3, 457]], type=Int16))
1896
def test03_truncate(self):
1897
"""Checking EArray.truncate() method (truncating to > earray.nrows)"""
1900
print '\n', '-=' * 30
1901
print "Running %s.test03_truncate..." % self.__class__.__name__
1903
# Create an instance of an HDF5 Table
1904
file = tempfile.mktemp(".h5")
1905
fileh = openFile(file, "w")
1908
arr = Atom(shape=(0, 2), dtype=Int16)
1909
array1 = fileh.createEArray(fileh.root, 'array1', arr, "title array1")
1911
array1.append(array([[456, 2],[3, 457]], type=Int16))
1915
fileh = openFile(file, mode = "a")
1916
array1 = fileh.root.array1
1918
# Truncate to 3 element
1919
size = array1.truncate(3)
1923
print "(closing file version)"
1925
fileh = openFile(file, mode = "r")
1926
array1 = fileh.root.array1
1929
print "array1-->", array1.read()
1930
print "size-->", size
1933
assert allequal(array1.read(), array([[456, 2],[3, 457]], type=Int16))
1936
class TruncateOpenTestCase(TruncateTestCase):
1939
class TruncateCloseTestCase(TruncateTestCase):
1943
#----------------------------------------------------------------------
1946
theSuite = unittest.TestSuite()
1950
#theSuite.addTest(unittest.makeSuite(BasicWriteTestCase))
1951
# theSuite.addTest(unittest.makeSuite(TruncateOpenTestCase))
1952
# theSuite.addTest(unittest.makeSuite(TruncateCloseTestCase))
1953
for n in range(niter):
1954
theSuite.addTest(unittest.makeSuite(BasicWriteTestCase))
1955
theSuite.addTest(unittest.makeSuite(BasicWrite2TestCase))
1956
theSuite.addTest(unittest.makeSuite(EmptyEArrayTestCase))
1957
theSuite.addTest(unittest.makeSuite(EmptyEArray2TestCase))
1958
theSuite.addTest(unittest.makeSuite(SlicesEArrayTestCase))
1959
theSuite.addTest(unittest.makeSuite(Slices2EArrayTestCase))
1960
theSuite.addTest(unittest.makeSuite(Slices3EArrayTestCase))
1961
theSuite.addTest(unittest.makeSuite(Slices4EArrayTestCase))
1962
theSuite.addTest(unittest.makeSuite(EllipsisEArrayTestCase))
1963
theSuite.addTest(unittest.makeSuite(Ellipsis2EArrayTestCase))
1964
theSuite.addTest(unittest.makeSuite(Ellipsis3EArrayTestCase))
1965
theSuite.addTest(unittest.makeSuite(Ellipsis4EArrayTestCase))
1966
theSuite.addTest(unittest.makeSuite(Ellipsis5EArrayTestCase))
1967
theSuite.addTest(unittest.makeSuite(Ellipsis6EArrayTestCase))
1968
theSuite.addTest(unittest.makeSuite(Ellipsis7EArrayTestCase))
1969
theSuite.addTest(unittest.makeSuite(MD3WriteTestCase))
1970
theSuite.addTest(unittest.makeSuite(MD5WriteTestCase))
1971
theSuite.addTest(unittest.makeSuite(MD6WriteTestCase))
1972
theSuite.addTest(unittest.makeSuite(MD7WriteTestCase))
1973
theSuite.addTest(unittest.makeSuite(MD10WriteTestCase))
1974
theSuite.addTest(unittest.makeSuite(ZlibComprTestCase))
1975
theSuite.addTest(unittest.makeSuite(ZlibShuffleTestCase))
1976
theSuite.addTest(unittest.makeSuite(LZOComprTestCase))
1977
theSuite.addTest(unittest.makeSuite(LZOShuffleTestCase))
1978
theSuite.addTest(unittest.makeSuite(UCLComprTestCase))
1979
theSuite.addTest(unittest.makeSuite(UCLShuffleTestCase))
1980
theSuite.addTest(unittest.makeSuite(FloatTypeTestCase))
1981
theSuite.addTest(unittest.makeSuite(ComplexTypeTestCase))
1982
theSuite.addTest(unittest.makeSuite(CharTypeTestCase))
1983
theSuite.addTest(unittest.makeSuite(CharType2TestCase))
1984
theSuite.addTest(unittest.makeSuite(CharTypeComprTestCase))
1986
theSuite.addTest(unittest.makeSuite(Numeric1TestCase))
1987
theSuite.addTest(unittest.makeSuite(Numeric2TestCase))
1988
theSuite.addTest(unittest.makeSuite(NumericComprTestCase))
1989
theSuite.addTest(unittest.makeSuite(OffsetStrideTestCase))
1990
theSuite.addTest(unittest.makeSuite(Fletcher32TestCase))
1991
theSuite.addTest(unittest.makeSuite(AllFiltersTestCase))
1992
theSuite.addTest(unittest.makeSuite(CloseCopyTestCase))
1993
theSuite.addTest(unittest.makeSuite(OpenCopyTestCase))
1994
theSuite.addTest(unittest.makeSuite(CopyIndex1TestCase))
1995
theSuite.addTest(unittest.makeSuite(CopyIndex2TestCase))
1996
theSuite.addTest(unittest.makeSuite(CopyIndex3TestCase))
1997
theSuite.addTest(unittest.makeSuite(CopyIndex4TestCase))
1998
theSuite.addTest(unittest.makeSuite(CopyIndex5TestCase))
1999
theSuite.addTest(unittest.makeSuite(CopyIndex6TestCase))
2000
theSuite.addTest(unittest.makeSuite(CopyIndex7TestCase))
2001
theSuite.addTest(unittest.makeSuite(CopyIndex8TestCase))
2002
theSuite.addTest(unittest.makeSuite(CopyIndex9TestCase))
2003
theSuite.addTest(unittest.makeSuite(CopyIndex10TestCase))
2004
theSuite.addTest(unittest.makeSuite(CopyIndex11TestCase))
2005
theSuite.addTest(unittest.makeSuite(CopyIndex12TestCase))
2006
theSuite.addTest(unittest.makeSuite(TruncateOpenTestCase))
2007
theSuite.addTest(unittest.makeSuite(TruncateCloseTestCase))
2012
if __name__ == '__main__':
2013
unittest.main( defaultTest='suite' )
2017
## py-indent-offset: 4