1
# Eh! python!, We are going to include isolatin characters here
2
# -*- coding: latin-1 -*-
10
from numarray import strings
12
from tables.utils import convertNAToNumeric, convertNAToNumPy
26
from common import verbose, allequal, cleanup, heavy
27
# To delete the internal attributes automagically
28
unittest.TestCase.tearDown = cleanup
30
class BasicTestCase(unittest.TestCase):
41
complib = "zlib" # Default compression library
44
reopen = 1 # Tells whether the file has to be reopened on each test or not
48
# Create an instance of an HDF5 Table
49
self.file = tempfile.mktemp(".h5")
50
self.fileh = openFile(self.file, "w")
51
self.rootgroup = self.fileh.root
57
def populateFile(self):
58
group = self.rootgroup
59
if self.flavor == "numarray":
60
if str(self.type) == "CharType":
64
elif self.flavor == "numpy":
68
if self.type == "CharType":
69
atom = StringAtom(shape=self.chunksize, length=self.length,
72
atom = Atom(dtype=self.type, shape=self.chunksize, flavor=flavor)
73
title = self.__class__.__name__
74
filters = Filters(complevel = self.compress,
75
complib = self.complib,
76
shuffle = self.shuffle,
77
fletcher32 = self.fletcher32)
78
carray = self.fileh.createCArray(group, 'carray1', self.shape, atom,
79
title, filters = filters)
82
self.rowshape = list(carray.shape)
83
self.objsize = self.length*product(self.shape)
84
if self.flavor == "numarray":
85
if str(self.type) == "CharType":
86
object = strings.array("a"*self.objsize, shape=self.shape,
87
itemsize=carray.itemsize)
89
object = arange(self.objsize, shape=self.shape,
91
elif self.flavor == "numpy":
92
object = numpy.arange(self.objsize,
93
dtype=numpy.typeNA[carray.type])
94
object = numpy.reshape(object, self.shape)
95
else: # Numeric flavor
96
object = Numeric.arange(self.objsize,
97
typecode=typecode[carray.type])
98
object = Numeric.reshape(object, self.shape)
100
if self.flavor == "numarray":
101
print "Object to append -->", object.info()
103
print "Object to append -->", repr(object)
105
if str(self.type) == "CharType":
107
elif self.flavor == "numarray":
110
# For Numeric arrays, we still have to undo the type upgrade
111
#carray[...] = object.astype(typecode[carray.type])
120
#----------------------------------------
122
def test01_readCArray(self):
123
"""Checking read() of chunked layout arrays"""
125
rootgroup = self.rootgroup
127
print '\n', '-=' * 30
128
print "Running %s.test01_readCArray..." % self.__class__.__name__
130
# Create an instance of an HDF5 Table
132
self.fileh = openFile(self.file, "r")
133
carray = self.fileh.getNode("/carray1")
135
# Choose a small value for buffer size
136
carray._v_maxTuples = 3
138
print "CArray descr:", repr(carray)
139
print "shape of read array ==>", carray.shape
140
print "reopening?:", self.reopen
142
# Build the array to do comparisons
143
if self.flavor == "numarray":
144
if str(self.type) == "CharType":
145
object_ = strings.array("a"*self.objsize, shape=self.shape,
146
itemsize=carray.itemsize)
148
object_ = arange(self.objsize, shape=self.shape,
150
elif self.flavor == "numpy":
151
object_ = numpy.arange(self.objsize,
152
dtype=numpy.typeNA[carray.type])
153
object_ = numpy.reshape(object_, self.shape)
155
object_ = Numeric.arange(self.objsize,
156
typecode=typecode[carray.type])
157
object_ = Numeric.reshape(object_, self.shape)
160
# stop == None means read only the element designed by start
161
# (in read() contexts)
162
if self.stop == None:
163
if self.start == -1: # corner case
166
stop = self.start + 1
167
# Protection against number of elements less than existing
168
#if rowshape[self.extdim] < self.stop or self.stop == 0:
169
if carray.nrows < stop:
170
# self.stop == 0 means last row only in read()
171
# and not in [::] slicing notation
173
# do a copy() in order to ensure that len(object._data)
174
# actually do a measure of its length
175
# Numeric 23.8 will issue an error with slices like -1:20:20
176
# but this is an error with this Numeric version (and perhaps
178
object = object_[self.start:stop:self.step].copy()
182
data = carray.read(self.start,stop,self.step)
184
if self.flavor == "numarray":
185
data = array(None, shape = self.shape, type=self.type)
186
elif self.flavor == "numpy":
187
data = numpy.empty(self.shape, numpy.typeNA[self.type])
189
data = Numeric.zeros(self.shape, typecode[self.type])
192
if hasattr(object, "shape"):
193
print "shape should look as:", object.shape
194
print "Object read ==>", repr(data)
195
print "Should look like ==>", repr(object)
197
if hasattr(data, "shape"):
198
assert len(data.shape) == len(self.shape)
201
assert len(self.shape) == 1
202
assert carray._v_chunksize == self.chunksize
203
assert allequal(data, object, self.flavor)
205
def test02_getitemCArray(self):
206
"""Checking chunked layout array __getitem__ special method"""
208
rootgroup = self.rootgroup
210
print '\n', '-=' * 30
211
print "Running %s.test02_getitemCArray..." % self.__class__.__name__
213
if not hasattr(self, "slices"):
214
# If there is not a slices attribute, create it
215
self.slices = (slice(self.start, self.stop, self.step),)
217
# Create an instance of an HDF5 Table
219
self.fileh = openFile(self.file, "r")
220
carray = self.fileh.getNode("/carray1")
222
# Choose a small value for buffer size
223
#carray._v_maxTuples = 3 # this does not really changes the chunksize
225
print "CArray descr:", repr(carray)
226
print "shape of read array ==>", carray.shape
227
print "reopening?:", self.reopen
229
# Build the array to do comparisons
230
if str(self.type) == "CharType":
231
object_ = strings.array("a"*self.objsize, shape=self.shape,
232
itemsize=carray.itemsize)
234
object_ = arange(self.objsize, shape=self.shape,
238
# do a copy() in order to ensure that len(object._data)
239
# actually do a measure of its length
240
object = object_.__getitem__(self.slices).copy()
242
if self.flavor == "numpy":
243
# Convert the object to Numeric
244
object = convertNAToNumPy(object)
245
elif self.flavor == "numeric":
246
# Convert the object to Numeric
247
object = convertNAToNumeric(object)
249
# Read data from the array
251
data = carray.__getitem__(self.slices)
254
if self.flavor == "numarray":
255
data = array(None, shape = self.shape, type=self.type)
256
elif self.flavor == "numpy":
257
data = numpy.empty(self.shape, numpy.typeNA[self.type])
259
data = Numeric.zeros(self.shape, typecode[self.type])
262
print "Object read:\n", repr(data) #, data.info()
263
print "Should look like:\n", repr(object) #, objact.info()
264
if hasattr(object, "shape"):
265
print "Original object shape:", self.shape
266
print "Shape read:", data.shape
267
print "shape should look as:", object.shape
269
if not hasattr(data, "shape"):
271
assert len(self.shape) == 1
272
assert carray._v_chunksize == self.chunksize
273
assert allequal(data, object, self.flavor)
275
def test03_setitemCArray(self):
276
"""Checking chunked layout array __setitem__ special method"""
278
rootgroup = self.rootgroup
279
if self.__class__.__name__ == "Ellipsis6CArrayTestCase":
280
# see test_earray.py BasicTestCase.test03_setitemEArray
283
print '\n', '-=' * 30
284
print "Running %s.test03_setitemCArray..." % self.__class__.__name__
286
if not hasattr(self, "slices"):
287
# If there is not a slices attribute, create it
288
self.slices = (slice(self.start, self.stop, self.step),)
290
# Create an instance of an HDF5 Table
292
self.fileh = openFile(self.file, "a")
293
carray = self.fileh.getNode("/carray1")
295
# Choose a small value for buffer size
296
#carray._v_maxTuples = 3 # this does not really changes the chunksize
298
print "CArray descr:", repr(carray)
299
print "shape of read array ==>", carray.shape
300
print "reopening?:", self.reopen
302
# Build the array to do comparisons
303
if str(self.type) == "CharType":
304
object_ = strings.array("a"*self.objsize, shape=self.shape,
305
itemsize=carray.itemsize)
307
object_ = arange(self.objsize, shape=self.shape,
311
# do a copy() in order to ensure that len(object._data)
312
# actually do a measure of its length
313
object = object_.__getitem__(self.slices).copy()
315
if self.flavor == "numpy":
316
# Convert the object to NumPy
317
object = convertNAToNumPy(object)
318
elif self.flavor == "numeric":
319
# Convert the object to Numeric
320
object = convertNAToNumeric(object)
322
if str(self.type) == "CharType":
323
if hasattr(self, "wslice"):
324
object[self.wslize] = object[self.wslice].pad("xXx")
325
carray[self.wslice] = carray[self.wslice].pad("xXx")
326
elif sum(object[self.slices].shape) <> 0 :
327
object[:] = object.pad("xXx")
328
if object.size() > 0:
329
carray[self.slices] = object
331
if hasattr(self, "wslice"):
332
object[self.wslice] = object[self.wslice] * 2 + 3
333
carray[self.wslice] = carray[self.wslice] * 2 + 3
334
elif sum(object[self.slices].shape) <> 0:
335
object = object * 2 + 3
336
if reduce(lambda x,y:x*y, object.shape) > 0:
337
carray[self.slices] = carray[self.slices] * 2 + 3
338
# Cast again object to its original type
339
object = array(object,type=carray.type)
340
# Read datafrom the array
342
data = carray.__getitem__(self.slices)
345
if self.flavor == "numarray":
346
data = array(None, shape = self.shape, type=self.type)
347
elif self.flavor == "numarray":
348
data = numpy.empty(self.shape, numpy.typeNA[self.type])
350
data = Numeric.zeros(self.shape, typecode[self.type])
353
print "Object read:\n", repr(data) #, data.info()
354
print "Should look like:\n", repr(object) #, object.info()
355
if hasattr(object, "shape"):
356
print "Original object shape:", self.shape
357
print "Shape read:", data.shape
358
print "shape should look as:", object.shape
360
if not hasattr(data, "shape"):
362
assert len(self.shape) == 1
363
assert carray._v_chunksize == self.chunksize
364
assert allequal(data, object, self.flavor)
367
class BasicWriteTestCase(BasicTestCase):
372
wslice = 1 # single element case
374
class BasicWrite2TestCase(BasicTestCase):
379
wslice = slice(shape[0]-2,shape[0],2) # range of elements
380
reopen = 0 # This case does not reopen files
382
class EmptyCArrayTestCase(BasicTestCase):
390
class EmptyCArray2TestCase(BasicTestCase):
397
reopen = 0 # This case does not reopen files
399
class SlicesCArrayTestCase(BasicTestCase):
405
slices = (slice(1,2,1), slice(1,3,1))
407
class EllipsisCArrayTestCase(BasicTestCase):
411
#slices = (slice(1,2,1), Ellipsis)
412
slices = (Ellipsis, slice(1,2,1))
414
class Slices2CArrayTestCase(BasicTestCase):
419
chunksize = (5, 5, 5)
420
slices = (slice(1,2,1), slice(None, None, None), slice(1,4,2))
422
class Ellipsis2CArrayTestCase(BasicTestCase):
425
chunksize = (5, 5, 5)
426
slices = (slice(1,2,1), Ellipsis, slice(1,4,2))
428
class Slices3CArrayTestCase(BasicTestCase):
429
compress = 1 # To show the chunks id DEBUG is on
433
chunksize = (5, 5, 5, 5)
434
slices = (slice(1, 2, 1), slice(0, None, None), slice(1,4,2)) # Don't work
435
#slices = (slice(None, None, None), slice(0, None, None), slice(1,4,1)) # W
436
#slices = (slice(None, None, None), slice(None, None, None), slice(1,4,2)) # N
437
#slices = (slice(1,2,1), slice(None, None, None), slice(1,4,2)) # N
438
# Disable the failing test temporarily with a working test case
439
slices = (slice(1,2,1), slice(1, 4, None), slice(1,4,2)) # Y
440
#slices = (slice(1,2,1), slice(0, 4, None), slice(1,4,1)) # Y
441
slices = (slice(1,2,1), slice(0, 4, None), slice(1,4,2)) # N
442
#slices = (slice(1,2,1), slice(0, 4, None), slice(1,4,2), slice(0,100,1)) # N
444
class Slices4CArrayTestCase(BasicTestCase):
446
shape = (2, 3, 4, 2, 5, 6)
447
chunksize = (5,5, 5, 5, 5, 5)
448
slices = (slice(1, 2, 1), slice(0, None, None), slice(1,4,2),
449
slice(0,4,2), slice(3,5,2), slice(2,7,1))
451
class Ellipsis3CArrayTestCase(BasicTestCase):
454
chunksize = (5, 5, 5, 5)
455
slices = (Ellipsis, slice(0, 4, None), slice(1,4,2))
456
slices = (slice(1,2,1), slice(0, 4, None), slice(1,4,2), Ellipsis)
458
class Ellipsis4CArrayTestCase(BasicTestCase):
461
chunksize = (5, 5, 5, 5)
462
slices = (Ellipsis, slice(0, 4, None), slice(1,4,2))
463
slices = (slice(1,2,1), Ellipsis, slice(1,4,2))
465
class Ellipsis5CArrayTestCase(BasicTestCase):
468
chunksize = (5, 5, 5, 5)
469
slices = (slice(1,2,1), slice(0, 4, None), Ellipsis)
471
class Ellipsis6CArrayTestCase(BasicTestCase):
474
chunksize = (5, 5, 5, 5)
475
# The next slices gives problems with setting values (test03)
476
# This is a problem on the test design, not the Array.__setitem__
477
# code, though. See # see test_earray.py Ellipsis6EArrayTestCase
478
slices = (slice(1,2,1), slice(0, 4, None), 2, Ellipsis)
480
class Ellipsis7CArrayTestCase(BasicTestCase):
483
chunksize = (5, 5, 5, 5)
484
slices = (slice(1,2,1), slice(0, 4, None), slice(2,3), Ellipsis)
486
class MD3WriteTestCase(BasicTestCase):
489
chunksize = (4, 4, 4)
492
class MD5WriteTestCase(BasicTestCase):
494
shape = (2, 2, 3, 4, 5) # ok
495
#shape = (1, 1, 2, 1) # Minimum shape that shows problems with HDF5 1.6.1
496
#shape = (2, 3, 2, 4, 5) # Floating point exception (HDF5 1.6.1)
497
#shape = (2, 3, 3, 2, 5, 6) # Segmentation fault (HDF5 1.6.1)
498
chunksize = (1, 1, 1, 1, 1)
503
class MD6WriteTestCase(BasicTestCase):
505
shape = (2, 3, 3, 2, 5, 6)
506
chunksize = (1, 1, 1, 1, 1, 1)
511
class MD6WriteTestCase__(BasicTestCase):
519
class MD7WriteTestCase(BasicTestCase):
521
shape = (2, 3, 3, 4, 5, 2, 3)
522
chunksize = (10, 10, 10, 10, 10, 10, 10)
527
class MD10WriteTestCase(BasicTestCase):
529
shape = (1, 2, 3, 4, 5, 5, 4, 3, 2, 2)
530
chunksize = (5, 5, 5, 5, 5, 5, 5, 5, 5, 5)
535
class ZlibComprTestCase(BasicTestCase):
539
#stop = 0 # means last row
540
stop = None # means last row from 0.8 on
543
class ZlibShuffleTestCase(BasicTestCase):
547
# case start < stop , i.e. no rows read
552
class LZOComprTestCase(BasicTestCase):
560
class LZOShuffleTestCase(BasicTestCase):
565
chunksize = (100,100)
570
class BZIP2ComprTestCase(BasicTestCase):
574
chunksize = (100,100)
579
class BZIP2ShuffleTestCase(BasicTestCase):
584
chunksize = (100,100)
589
class Fletcher32TestCase(BasicTestCase):
598
class AllFiltersTestCase(BasicTestCase):
603
chunksize = (20,20) # sss
608
class FloatTypeTestCase(BasicTestCase):
616
class ComplexTypeTestCase(BasicTestCase):
624
class CharTypeTestCase(BasicTestCase):
633
slices = (slice(0,1),slice(1,2))
635
class CharType2TestCase(BasicTestCase):
644
class CharTypeComprTestCase(BasicTestCase):
648
#shape = (20,0,10,20)
650
#shuffle = 1 # this shouldn't do nothing on chars
651
chunksize = (50,50,2)
656
class NumpyInt8TestCase(BasicTestCase):
667
class NumpyInt16TestCase(BasicTestCase):
678
class NumpyInt32TestCase(BasicTestCase):
689
class NumpyFloat32TestCase(BasicTestCase):
700
class NumpyFloat64TestCase(BasicTestCase):
711
class NumpyComplex32TestCase(BasicTestCase):
722
class NumpyComplex64TestCase(BasicTestCase):
733
class NumpyComprTestCase(BasicTestCase):
745
class NumericInt8TestCase(BasicTestCase):
756
class NumericInt16TestCase(BasicTestCase):
767
class NumericInt32TestCase(BasicTestCase):
778
class NumericFloat32TestCase(BasicTestCase):
789
class NumericFloat64TestCase(BasicTestCase):
800
class NumericComplex32TestCase(BasicTestCase):
811
class NumericComplex64TestCase(BasicTestCase):
822
class NumericComprTestCase(BasicTestCase):
834
# It remains a test of Numeric char types, but the code is getting too messy
836
class OffsetStrideTestCase(unittest.TestCase):
839
complib = "zlib" # Default compression library
843
# Create an instance of an HDF5 Table
844
self.file = tempfile.mktemp(".h5")
845
self.fileh = openFile(self.file, self.mode)
846
self.rootgroup = self.fileh.root
853
#----------------------------------------
855
def test01a_String(self):
856
"""Checking carray with offseted numarray strings appends"""
858
root = self.rootgroup
860
print '\n', '-=' * 30
861
print "Running %s.test01a_String..." % self.__class__.__name__
864
# Create an string atom
865
carray = self.fileh.createCArray(root, 'strings', shape,
866
StringAtom(length=3, shape=(1,2,2)),
868
a=strings.array([[["a","b"],["123", "45"],["45", "123"]]], itemsize=3)
870
a=strings.array([[["s", "a"],["ab", "f"],["s", "abc"],["abc", "f"]]])
876
print "Object read:", data
877
print "Nrows in", carray._v_pathname, ":", carray.nrows
878
print "Second row in carray ==>", data[1].tolist()
880
assert carray.nrows == 3
881
assert data[0].tolist() == [["123", "45"],["45", "123"]]
882
assert data[1].tolist() == [["s", "abc"],["abc", "f"]]
883
assert len(data[0]) == 2
884
assert len(data[1]) == 2
886
def test01b_String(self):
887
"""Checking carray with strided numarray strings appends"""
889
root = self.rootgroup
891
print '\n', '-=' * 30
892
print "Running %s.test01b_String..." % self.__class__.__name__
895
# Create an string atom
896
carray = self.fileh.createCArray(root, 'strings', shape,
897
StringAtom(length=3, shape=(1,2,2)),
899
a=strings.array([[["a","b"],["123", "45"],["45", "123"]]], itemsize=3)
901
a=strings.array([[["s", "a"],["ab", "f"],["s", "abc"],["abc", "f"]]])
907
print "Object read:", data
908
print "Nrows in", carray._v_pathname, ":", carray.nrows
909
print "Second row in carray ==>", data[1].tolist()
911
assert carray.nrows == 3
912
assert data[0].tolist() == [["a","b"],["45", "123"]]
913
assert data[1].tolist() == [["s", "a"],["s", "abc"]]
914
assert len(data[0]) == 2
915
assert len(data[1]) == 2
917
def test02a_int(self):
918
"""Checking carray with offseted numarray ints appends"""
920
root = self.rootgroup
922
print '\n', '-=' * 30
923
print "Running %s.test02a_int..." % self.__class__.__name__
926
# Create an string atom
927
carray = self.fileh.createCArray(root, 'CAtom', shape,
928
Int32Atom(shape=(1,3)),
930
a=array([(0,0,0), (1,0,3), (1,1,1), (0,0,0)], type=Int32)
931
carray[0:2] = a[2:] # Introduce an offset
932
a=array([(1,1,1), (-1,0,0)], type=Int32)
933
carray[2:3] = a[1:] # Introduce an offset
938
print "Object read:", data
939
print "Nrows in", carray._v_pathname, ":", carray.nrows
940
print "Third row in carray ==>", data[2]
942
assert carray.nrows == 3
943
assert allequal(data[0], array([1,1,1], type=Int32))
944
assert allequal(data[1], array([0,0,0], type=Int32))
945
assert allequal(data[2], array([-1,0,0], type=Int32))
947
def test02b_int(self):
948
"""Checking carray with strided numarray ints appends"""
950
root = self.rootgroup
952
print '\n', '-=' * 30
953
print "Running %s.test02b_int..." % self.__class__.__name__
956
# Create an string atom
957
carray = self.fileh.createCArray(root, 'CAtom', shape,
958
Int32Atom(shape=(1,3)),
960
a=array([(0,0,0), (1,0,3), (1,1,1), (3,3,3)], type=Int32)
961
carray[0:2] = a[::3] # Create an offset
962
a=array([(1,1,1), (-1,0,0)], type=Int32)
963
carray[2:3] = a[::2] # Create an offset
968
print "Object read:", data
969
print "Nrows in", carray._v_pathname, ":", carray.nrows
970
print "Third row in carray ==>", data[2]
972
assert carray.nrows == 3
973
assert allequal(data[0], array([0,0,0], type=Int32))
974
assert allequal(data[1], array([3,3,3], type=Int32))
975
assert allequal(data[2], array([1,1,1], type=Int32))
978
class NumpyOffsetStrideTestCase(unittest.TestCase):
981
complib = "zlib" # Default compression library
985
# Create an instance of an HDF5 Table
986
self.file = tempfile.mktemp(".h5")
987
self.fileh = openFile(self.file, self.mode)
988
self.rootgroup = self.fileh.root
995
#----------------------------------------
997
def test02a_int(self):
998
"""Checking carray with offseted NumPy ints appends"""
1000
root = self.rootgroup
1002
print '\n', '-=' * 30
1003
print "Running %s.test02a_int..." % self.__class__.__name__
1006
# Create an string atom
1007
carray = self.fileh.createCArray(root, 'CAtom', shape,
1008
Int32Atom(shape=(1,3)),
1010
a=numpy.array([(0,0,0), (1,0,3), (1,1,1), (0,0,0)], dtype='int32')
1011
carray[0:2] = a[2:] # Introduce an offset
1012
a=numpy.array([(1,1,1), (-1,0,0)], dtype='int32')
1013
carray[2:3] = a[1:] # Introduce an offset
1015
# Read all the rows:
1016
data = carray.read()
1018
print "Object read:", data
1019
print "Nrows in", carray._v_pathname, ":", carray.nrows
1020
print "Third row in carray ==>", data[2]
1022
assert carray.nrows == 3
1023
assert allequal(data[0], array([1,1,1], typecode='i'))
1024
assert allequal(data[1], array([0,0,0], typecode='i'))
1025
assert allequal(data[2], array([-1,0,0], typecode='i'))
1027
def test02b_int(self):
1028
"""Checking carray with strided NumPy ints appends"""
1030
root = self.rootgroup
1032
print '\n', '-=' * 30
1033
print "Running %s.test02b_int..." % self.__class__.__name__
1036
# Create an string atom
1037
carray = self.fileh.createCArray(root, 'CAtom', shape,
1038
Int32Atom(shape=(1,3)),
1040
a=numpy.array([(0,0,0), (1,0,3), (1,2,1), (3,2,3)], dtype='int32')
1041
carray[0:2] = a[::3] # Create a strided object
1042
a=numpy.array([(1,0,1), (-1,0,0)], dtype='int32')
1043
carray[2:3] = a[::2] # Create a strided object
1045
# Read all the rows:
1046
data = carray.read()
1048
print "Object read:", data
1049
print "Nrows in", carray._v_pathname, ":", carray.nrows
1050
print "Third row in carray ==>", data[2]
1052
assert carray.nrows == 3
1053
assert allequal(data[0], array([0,0,0], typecode='i'))
1054
assert allequal(data[1], array([3,2,3], typecode='i'))
1055
assert allequal(data[2], array([1,0,1], typecode='i'))
1058
class NumericOffsetStrideTestCase(unittest.TestCase):
1061
complib = "zlib" # Default compression library
1065
# Create an instance of an HDF5 Table
1066
self.file = tempfile.mktemp(".h5")
1067
self.fileh = openFile(self.file, self.mode)
1068
self.rootgroup = self.fileh.root
1072
os.remove(self.file)
1075
#----------------------------------------
1077
def test02a_int(self):
1078
"""Checking carray with offseted Numeric ints appends"""
1080
root = self.rootgroup
1082
print '\n', '-=' * 30
1083
print "Running %s.test02a_int..." % self.__class__.__name__
1086
# Create an string atom
1087
carray = self.fileh.createCArray(root, 'CAtom', shape,
1088
Int32Atom(shape=(1,3)),
1090
a=Numeric.array([(0,0,0), (1,0,3), (1,1,1), (0,0,0)], typecode='i')
1091
carray[0:2] = a[2:] # Introduce an offset
1092
a=Numeric.array([(1,1,1), (-1,0,0)], typecode='i')
1093
carray[2:3] = a[1:] # Introduce an offset
1095
# Read all the rows:
1096
data = carray.read()
1098
print "Object read:", data
1099
print "Nrows in", carray._v_pathname, ":", carray.nrows
1100
print "Third row in carray ==>", data[2]
1102
assert carray.nrows == 3
1103
assert allequal(data[0], array([1,1,1], typecode='i'))
1104
assert allequal(data[1], array([0,0,0], typecode='i'))
1105
assert allequal(data[2], array([-1,0,0], typecode='i'))
1107
def test02b_int(self):
1108
"""Checking carray with strided Numeric ints appends"""
1110
root = self.rootgroup
1112
print '\n', '-=' * 30
1113
print "Running %s.test02b_int..." % self.__class__.__name__
1116
# Create an string atom
1117
carray = self.fileh.createCArray(root, 'CAtom', shape,
1118
Int32Atom(shape=(1,3)),
1120
a=Numeric.array([(0,0,0), (1,0,3), (1,2,1), (3,2,3)], typecode='i')
1121
carray[0:2] = a[::3] # Create a strided object
1122
a=Numeric.array([(1,0,1), (-1,0,0)], typecode='i')
1123
carray[2:3] = a[::2] # Create a strided object
1125
# Read all the rows:
1126
data = carray.read()
1128
print "Object read:", data
1129
print "Nrows in", carray._v_pathname, ":", carray.nrows
1130
print "Third row in carray ==>", data[2]
1132
assert carray.nrows == 3
1133
assert allequal(data[0], array([0,0,0], typecode='i'))
1134
assert allequal(data[1], array([3,2,3], typecode='i'))
1135
assert allequal(data[2], array([1,0,1], typecode='i'))
1138
class CopyTestCase(unittest.TestCase):
1140
def test01a_copy(self):
1141
"""Checking CArray.copy() method """
1144
print '\n', '-=' * 30
1145
print "Running %s.test01a_copy..." % self.__class__.__name__
1147
# Create an instance of an HDF5 Table
1148
file = tempfile.mktemp(".h5")
1149
fileh = openFile(file, "w")
1153
arr = Atom(shape=(2, 2), dtype=Int16)
1154
array1 = fileh.createCArray(fileh.root, 'array1', shape, arr,
1156
array1[...] = array([[456, 2],[3, 457]], type=Int16)
1160
print "(closing file version)"
1162
fileh = openFile(file, mode = "a")
1163
array1 = fileh.root.array1
1165
# Copy it to another location
1166
array2 = array1.copy('/', 'array2')
1170
print "(closing file version)"
1172
fileh = openFile(file, mode = "r")
1173
array1 = fileh.root.array1
1174
array2 = fileh.root.array2
1177
print "array1-->", array1.read()
1178
print "array2-->", array2.read()
1179
#print "dirs-->", dir(array1), dir(array2)
1180
print "attrs array1-->", repr(array1.attrs)
1181
print "attrs array2-->", repr(array2.attrs)
1183
# Check that all the elements are equal
1184
assert allequal(array1.read(), array2.read())
1186
# Assert other properties in array
1187
assert array1.nrows == array2.nrows
1188
assert array1.shape == array2.shape
1189
assert array1.extdim == array2.extdim
1190
assert array1.flavor == array2.flavor
1191
assert array1.type == array2.type
1192
assert array1.itemsize == array2.itemsize
1193
assert array1.title == array2.title
1194
assert str(array1.atom) == str(array2.atom)
1195
assert array1._v_chunksize == array2._v_chunksize
1201
def test01b_copy(self):
1202
"""Checking CArray.copy() method """
1205
print '\n', '-=' * 30
1206
print "Running %s.test01b_copy..." % self.__class__.__name__
1208
# Create an instance of an HDF5 Table
1209
file = tempfile.mktemp(".h5")
1210
fileh = openFile(file, "w")
1214
arr = Atom(shape=(5, 5), dtype=Int16)
1215
array1 = fileh.createCArray(fileh.root, 'array1', shape, arr,
1217
array1[...] = array([[456, 2],[3, 457]], type=Int16)
1221
print "(closing file version)"
1223
fileh = openFile(file, mode = "a")
1224
array1 = fileh.root.array1
1226
# Copy it to another location
1227
array2 = array1.copy('/', 'array2')
1231
print "(closing file version)"
1233
fileh = openFile(file, mode = "r")
1234
array1 = fileh.root.array1
1235
array2 = fileh.root.array2
1238
print "array1-->", array1.read()
1239
print "array2-->", array2.read()
1240
#print "dirs-->", dir(array1), dir(array2)
1241
print "attrs array1-->", repr(array1.attrs)
1242
print "attrs array2-->", repr(array2.attrs)
1244
# Check that all the elements are equal
1245
assert allequal(array1.read(), array2.read())
1247
# Assert other properties in array
1248
assert array1.nrows == array2.nrows
1249
assert array1.shape == array2.shape
1250
assert array1.extdim == array2.extdim
1251
assert array1.flavor == array2.flavor
1252
assert array1.type == array2.type
1253
assert array1.itemsize == array2.itemsize
1254
assert array1.title == array2.title
1255
assert str(array1.atom) == str(array2.atom)
1256
assert array1._v_chunksize == array2._v_chunksize
1262
def test01c_copy(self):
1263
"""Checking CArray.copy() method """
1266
print '\n', '-=' * 30
1267
print "Running %s.test01c_copy..." % self.__class__.__name__
1269
# Create an instance of an HDF5 Table
1270
file = tempfile.mktemp(".h5")
1271
fileh = openFile(file, "w")
1275
arr = Atom(shape=(2, 2), dtype=Int16)
1276
array1 = fileh.createCArray(fileh.root, 'array1', shape, arr,
1278
array1[:2,:2] = array([[456, 2],[3, 457]], type=Int16)
1282
print "(closing file version)"
1284
fileh = openFile(file, mode = "a")
1285
array1 = fileh.root.array1
1287
# Copy it to another location
1288
array2 = array1.copy('/', 'array2')
1292
print "(closing file version)"
1294
fileh = openFile(file, mode = "r")
1295
array1 = fileh.root.array1
1296
array2 = fileh.root.array2
1299
print "array1-->", array1.read()
1300
print "array2-->", array2.read()
1301
#print "dirs-->", dir(array1), dir(array2)
1302
print "attrs array1-->", repr(array1.attrs)
1303
print "attrs array2-->", repr(array2.attrs)
1305
# Check that all the elements are equal
1306
assert allequal(array1.read(), array2.read())
1308
# Assert other properties in array
1309
assert array1.nrows == array2.nrows
1310
assert array1.shape == array2.shape
1311
assert array1.extdim == array2.extdim
1312
assert array1.flavor == array2.flavor
1313
assert array1.type == array2.type
1314
assert array1.itemsize == array2.itemsize
1315
assert array1.title == array2.title
1316
assert str(array1.atom) == str(array2.atom)
1317
assert array1._v_chunksize == array2._v_chunksize
1323
def test02_copy(self):
1324
"""Checking CArray.copy() method (where specified)"""
1327
print '\n', '-=' * 30
1328
print "Running %s.test02_copy..." % self.__class__.__name__
1330
# Create an instance of an HDF5 Table
1331
file = tempfile.mktemp(".h5")
1332
fileh = openFile(file, "w")
1336
arr = Atom(shape=(2, 2), dtype=Int16)
1337
array1 = fileh.createCArray(fileh.root, 'array1', shape, arr,
1339
array1[:2,:2] = array([[456, 2],[3, 457]], type=Int16)
1343
print "(closing file version)"
1345
fileh = openFile(file, mode = "a")
1346
array1 = fileh.root.array1
1348
# Copy to another location
1349
group1 = fileh.createGroup("/", "group1")
1350
array2 = array1.copy(group1, 'array2')
1354
print "(closing file version)"
1356
fileh = openFile(file, mode = "r")
1357
array1 = fileh.root.array1
1358
array2 = fileh.root.group1.array2
1361
print "array1-->", array1.read()
1362
print "array2-->", array2.read()
1363
#print "dirs-->", dir(array1), dir(array2)
1364
print "attrs array1-->", repr(array1.attrs)
1365
print "attrs array2-->", repr(array2.attrs)
1367
# Check that all the elements are equal
1368
assert allequal(array1.read(), array2.read())
1370
# Assert other properties in array
1371
assert array1.nrows == array2.nrows
1372
assert array1.shape == array2.shape
1373
assert array1.extdim == array2.extdim
1374
assert array1.flavor == array2.flavor
1375
assert array1.type == array2.type
1376
assert array1.itemsize == array2.itemsize
1377
assert array1.title == array2.title
1378
assert str(array1.atom) == str(array2.atom)
1379
assert array1._v_chunksize == array2._v_chunksize
1385
def test03_copy(self):
1386
"""Checking CArray.copy() method (Numeric flavor)"""
1389
print '\n', '-=' * 30
1390
print "Running %s.test03_copy..." % self.__class__.__name__
1392
# Create an instance of an HDF5 Table
1393
file = tempfile.mktemp(".h5")
1394
fileh = openFile(file, "w")
1397
arr = Atom(shape=(2, 2), dtype=Int16, flavor="numeric")
1399
arr = Atom(shape=(2, 2), dtype=Int16)
1402
array1 = fileh.createCArray(fileh.root, 'array1', shape, arr,
1404
array1[...] = array([[456, 2],[3, 457]], type=Int16)
1408
print "(closing file version)"
1410
fileh = openFile(file, mode = "a")
1411
array1 = fileh.root.array1
1413
# Copy to another location
1414
array2 = array1.copy('/', 'array2')
1418
print "(closing file version)"
1420
fileh = openFile(file, mode = "r")
1421
array1 = fileh.root.array1
1422
array2 = fileh.root.array2
1425
print "attrs array1-->", repr(array1.attrs)
1426
print "attrs array2-->", repr(array2.attrs)
1428
# Assert other properties in array
1429
assert array1.nrows == array2.nrows
1430
assert array1.shape == array2.shape
1431
assert array1.extdim == array2.extdim
1432
assert array1.flavor == array2.flavor # Very important here!
1433
assert array1.type == array2.type
1434
assert array1.itemsize == array2.itemsize
1435
assert array1.title == array2.title
1436
assert str(array1.atom) == str(array2.atom)
1437
assert array1._v_chunksize == array2._v_chunksize
1443
def test03c_copy(self):
1444
"""Checking CArray.copy() method (python flavor)"""
1447
print '\n', '-=' * 30
1448
print "Running %s.test03c_copy..." % self.__class__.__name__
1450
# Create an instance of an HDF5 Table
1451
file = tempfile.mktemp(".h5")
1452
fileh = openFile(file, "w")
1455
arr = Atom(shape=(2, 2), dtype=Int16, flavor="python")
1456
array1 = fileh.createCArray(fileh.root, 'array1', shape, arr,
1458
array1[...] = [[456, 2],[3, 457]]
1462
print "(closing file version)"
1464
fileh = openFile(file, mode = "a")
1465
array1 = fileh.root.array1
1467
# Copy to another location
1468
array2 = array1.copy('/', 'array2')
1472
print "(closing file version)"
1474
fileh = openFile(file, mode = "r")
1475
array1 = fileh.root.array1
1476
array2 = fileh.root.array2
1479
print "attrs array1-->", repr(array1.attrs)
1480
print "attrs array2-->", repr(array2.attrs)
1482
# Check that all elements are equal
1483
assert array1.read() == array2.read()
1484
# Assert other properties in array
1485
assert array1.nrows == array2.nrows
1486
assert array1.shape == array2.shape
1487
assert array1.extdim == array2.extdim
1488
assert array1.flavor == array2.flavor # Very important here!
1489
assert array1.type == array2.type
1490
assert array1.itemsize == array2.itemsize
1491
assert array1.title == array2.title
1492
assert str(array1.atom) == str(array2.atom)
1493
assert array1._v_chunksize == array2._v_chunksize
1499
def test03d_copy(self):
1500
"""Checking CArray.copy() method (string python flavor)"""
1503
print '\n', '-=' * 30
1504
print "Running %s.test03d_copy..." % self.__class__.__name__
1506
# Create an instance of an HDF5 Table
1507
file = tempfile.mktemp(".h5")
1508
fileh = openFile(file, "w")
1511
arr = StringAtom(shape=(2, 2), length=4, flavor="python")
1512
array1 = fileh.createCArray(fileh.root, 'array1', shape, arr,
1514
array1[...] = [["456", "2"],["3", "457"]]
1518
print "(closing file version)"
1520
fileh = openFile(file, mode = "a")
1521
array1 = fileh.root.array1
1523
# Copy to another location
1524
array2 = array1.copy('/', 'array2')
1528
print "(closing file version)"
1530
fileh = openFile(file, mode = "r")
1531
array1 = fileh.root.array1
1532
array2 = fileh.root.array2
1535
print "type value-->", type(array2[:][0][0])
1536
print "value-->", array2[:]
1537
print "attrs array1-->", repr(array1.attrs)
1538
print "attrs array2-->", repr(array2.attrs)
1540
# Check that all elements are equal
1541
assert array1.read() == array2.read()
1543
# Assert other properties in array
1544
assert array1.nrows == array2.nrows
1545
assert array1.shape == array2.shape
1546
assert array1.extdim == array2.extdim
1547
assert array1.flavor == array2.flavor # Very important here!
1548
assert array1.type == array2.type
1549
assert array1.itemsize == array2.itemsize
1550
assert array1.title == array2.title
1551
assert str(array1.atom) == str(array2.atom)
1552
assert array1._v_chunksize == array2._v_chunksize
1558
def test03e_copy(self):
1559
"""Checking CArray.copy() method (CharArray flavor)"""
1562
print '\n', '-=' * 30
1563
print "Running %s.test03e_copy..." % self.__class__.__name__
1565
# Create an instance of an HDF5 Table
1566
file = tempfile.mktemp(".h5")
1567
fileh = openFile(file, "w")
1570
arr = StringAtom(shape=(2, 2), length=4, flavor="numarray")
1571
array1 = fileh.createCArray(fileh.root, 'array1', shape, arr,
1573
array1[...] = strings.array([["456", "2"],["3", "457"]], itemsize=4)
1577
print "(closing file version)"
1579
fileh = openFile(file, mode = "a")
1580
array1 = fileh.root.array1
1582
# Copy to another location
1583
array2 = array1.copy('/', 'array2')
1587
print "(closing file version)"
1589
fileh = openFile(file, mode = "r")
1590
array1 = fileh.root.array1
1591
array2 = fileh.root.array2
1594
print "attrs array1-->", repr(array1.attrs)
1595
print "attrs array2-->", repr(array2.attrs)
1597
# Check that all elements are equal
1598
assert allequal(array1.read(), array2.read())
1599
# Assert other properties in array
1600
assert array1.nrows == array2.nrows
1601
assert array1.shape == array2.shape
1602
assert array1.extdim == array2.extdim
1603
assert array1.flavor == array2.flavor # Very important here!
1604
assert array1.type == array2.type
1605
assert array1.itemsize == array2.itemsize
1606
assert array1.title == array2.title
1607
assert str(array1.atom) == str(array2.atom)
1608
assert array1._v_chunksize == array2._v_chunksize
1614
def test04_copy(self):
1615
"""Checking CArray.copy() method (checking title copying)"""
1618
print '\n', '-=' * 30
1619
print "Running %s.test04_copy..." % self.__class__.__name__
1621
# Create an instance of an HDF5 Table
1622
file = tempfile.mktemp(".h5")
1623
fileh = openFile(file, "w")
1627
atom=Int16Atom(shape=(2,2))
1628
array1 = fileh.createCArray(fileh.root, 'array1', shape, atom,
1630
array1[...] = array([[456, 2],[3, 457]], type=Int16)
1631
# Append some user attrs
1632
array1.attrs.attr1 = "attr1"
1633
array1.attrs.attr2 = 2
1637
print "(closing file version)"
1639
fileh = openFile(file, mode = "a")
1640
array1 = fileh.root.array1
1642
# Copy it to another Array
1643
array2 = array1.copy('/', 'array2', title="title array2")
1647
print "(closing file version)"
1649
fileh = openFile(file, mode = "r")
1650
array1 = fileh.root.array1
1651
array2 = fileh.root.array2
1653
# Assert user attributes
1655
print "title of destination array-->", array2.title
1656
array2.title == "title array2"
1662
def test05_copy(self):
1663
"""Checking CArray.copy() method (user attributes copied)"""
1666
print '\n', '-=' * 30
1667
print "Running %s.test05_copy..." % self.__class__.__name__
1669
# Create an instance of an HDF5 Table
1670
file = tempfile.mktemp(".h5")
1671
fileh = openFile(file, "w")
1675
atom=Int16Atom(shape=(2,2))
1676
array1 = fileh.createCArray(fileh.root, 'array1', shape, atom,
1678
array1[...] = array([[456, 2],[3, 457]], type=Int16)
1679
# Append some user attrs
1680
array1.attrs.attr1 = "attr1"
1681
array1.attrs.attr2 = 2
1685
print "(closing file version)"
1687
fileh = openFile(file, mode = "a")
1688
array1 = fileh.root.array1
1690
# Copy it to another Array
1691
array2 = array1.copy('/', 'array2', copyuserattrs=1)
1695
print "(closing file version)"
1697
fileh = openFile(file, mode = "r")
1698
array1 = fileh.root.array1
1699
array2 = fileh.root.array2
1702
print "attrs array1-->", repr(array1.attrs)
1703
print "attrs array2-->", repr(array2.attrs)
1705
# Assert user attributes
1706
array2.attrs.attr1 == "attr1"
1707
array2.attrs.attr2 == 2
1713
def test05b_copy(self):
1714
"""Checking CArray.copy() method (user attributes not copied)"""
1717
print '\n', '-=' * 30
1718
print "Running %s.test05b_copy..." % self.__class__.__name__
1720
# Create an instance of an HDF5 Table
1721
file = tempfile.mktemp(".h5")
1722
fileh = openFile(file, "w")
1726
atom=Int16Atom(shape=(2,2))
1727
array1 = fileh.createCArray(fileh.root, 'array1', shape, atom,
1729
array1[...] = array([[456, 2],[3, 457]], type=Int16)
1730
# Append some user attrs
1731
array1.attrs.attr1 = "attr1"
1732
array1.attrs.attr2 = 2
1736
print "(closing file version)"
1738
fileh = openFile(file, mode = "a")
1739
array1 = fileh.root.array1
1741
# Copy it to another Array
1742
array2 = array1.copy('/', 'array2', copyuserattrs=0)
1746
print "(closing file version)"
1748
fileh = openFile(file, mode = "r")
1749
array1 = fileh.root.array1
1750
array2 = fileh.root.array2
1753
print "attrs array1-->", repr(array1.attrs)
1754
print "attrs array2-->", repr(array2.attrs)
1756
# Assert user attributes
1757
hasattr(array2.attrs, "attr1") == 0
1758
hasattr(array2.attrs, "attr2") == 0
1765
class CloseCopyTestCase(CopyTestCase):
1768
class OpenCopyTestCase(CopyTestCase):
1771
class CopyIndexTestCase(unittest.TestCase):
1774
def test01_index(self):
1775
"""Checking CArray.copy() method with indexes"""
1778
print '\n', '-=' * 30
1779
print "Running %s.test01_index..." % self.__class__.__name__
1781
# Create an instance of an HDF5 Array
1782
file = tempfile.mktemp(".h5")
1783
fileh = openFile(file, "w")
1787
atom = Int32Atom(shape=(2,2))
1788
array1 = fileh.createCArray(fileh.root, 'array1', shape, atom,
1790
r = arange(200, type=Int32, shape=(100,2))
1793
# Select a different buffer size:
1794
array1._v_maxTuples = self.maxTuples
1796
# Copy to another array
1797
array2 = array1.copy("/", 'array2',
1802
print "array1-->", array1.read()
1803
print "array2-->", array2.read()
1804
print "attrs array1-->", repr(array1.attrs)
1805
print "attrs array2-->", repr(array2.attrs)
1807
# Check that all the elements are equal
1808
r2 = r[self.start:self.stop:self.step]
1809
assert allequal(r2, array2.read())
1811
# Assert the number of rows in array
1813
print "nrows in array2-->", array2.nrows
1814
print "and it should be-->", r2.shape[0]
1816
assert array1._v_chunksize == array2._v_chunksize
1817
assert r2.shape[0] == array2.nrows
1823
def _test02_indexclosef(self):
1824
"""Checking CArray.copy() method with indexes (close file version)"""
1827
print '\n', '-=' * 30
1828
print "Running %s.test02_indexclosef..." % self.__class__.__name__
1830
# Create an instance of an HDF5 Array
1831
file = tempfile.mktemp(".h5")
1832
fileh = openFile(file, "w")
1836
atom = Int32Atom(shape=(2,2))
1837
array1 = fileh.createCArray(fileh.root, 'array1', shape, atom,
1839
r = arange(200, type=Int32, shape=(100,2))
1842
# Select a different buffer size:
1843
array1._v_maxTuples = self.maxTuples
1845
# Copy to another array
1846
array2 = array1.copy("/", 'array2',
1850
# Close and reopen the file
1852
fileh = openFile(file, mode = "r")
1853
array1 = fileh.root.array1
1854
array2 = fileh.root.array2
1857
print "array1-->", array1.read()
1858
print "array2-->", array2.read()
1859
print "attrs array1-->", repr(array1.attrs)
1860
print "attrs array2-->", repr(array2.attrs)
1862
# Check that all the elements are equal
1863
r2 = r[self.start:self.stop:self.step]
1864
assert array1._v_chunksize == array2._v_chunksize
1865
assert allequal(r2, array2.read())
1867
# Assert the number of rows in array
1869
print "nrows in array2-->", array2.nrows
1870
print "and it should be-->", r2.shape[0]
1871
assert r2.shape[0] == array2.nrows
1877
class CopyIndex1TestCase(CopyIndexTestCase):
1883
class CopyIndex2TestCase(CopyIndexTestCase):
1889
class CopyIndex3TestCase(CopyIndexTestCase):
1895
class CopyIndex4TestCase(CopyIndexTestCase):
1901
class CopyIndex5TestCase(CopyIndexTestCase):
1907
class CopyIndex6TestCase(CopyIndexTestCase):
1913
class CopyIndex7TestCase(CopyIndexTestCase):
1918
class CopyIndex8TestCase(CopyIndexTestCase):
1920
stop = -1 # Negative values means starting from the end
1923
class CopyIndex9TestCase(CopyIndexTestCase):
1928
class CopyIndex10TestCase(CopyIndexTestCase):
1934
class CopyIndex11TestCase(CopyIndexTestCase):
1939
class CopyIndex12TestCase(CopyIndexTestCase):
1940
start = -1 # Should point to the last element
1941
stop = None # None should mean the last element (including it)
1944
# The next test should be run only in **heavy** mode
1945
class Rows64bitsTestCase(unittest.TestCase):
1946
narows = 1000*1000L # each numarray will have 1 million entries
1947
#narows = 1000L # for testing only
1948
nanumber = 1000*3L # That should account for more than 2**31-1
1952
# Create an instance of an HDF5 Table
1953
self.file = tempfile.mktemp(".h5")
1954
fileh = self.fileh = openFile(self.file, "a")
1956
shape = (self.narows*self.nanumber,)
1957
array = fileh.createCArray(fileh.root, 'array', shape, Int8Atom((1024,)),
1958
filters=Filters(complib='lzo', complevel=1))
1961
na = arange(self.narows, type='Int8')
1962
#~ for i in xrange(self.nanumber):
1963
#~ s = slice(i*self.narows, (i+1)*self.narows)
1965
s = slice(0, self.narows)
1967
s = slice((self.nanumber-1)*self.narows, self.nanumber*self.narows)
1973
os.remove(self.file)
1976
#----------------------------------------
1978
def test01_basiccheck(self):
1979
"Some basic checks for carrays exceeding 2**31 rows"
1982
array = fileh.root.array
1986
# Check how many entries there are in the array
1987
print "Before closing"
1988
print "Entries:", array.nrows, type(array.nrows)
1989
print "Entries:", array.nrows / (1000*1000), "Millions"
1990
print "Shape:", array.shape
1994
fileh = self.fileh = openFile(self.file)
1995
array = fileh.root.array
1997
print "After re-open"
1999
# Check how many entries there are in the array
2001
print "Entries:", array.nrows, type(array.nrows)
2002
print "Entries:", array.nrows / (1000*1000), "Millions"
2003
print "Shape:", array.shape
2004
print "Last 10 elements-->", array[-10:]
2005
stop = self.narows%256
2009
#print "start, stop-->", start, stop
2010
print "Should look like-->", arange(start, stop, type='Int8')
2012
nrows = self.narows*self.nanumber
2014
assert array.nrows == nrows
2016
assert array.shape == (nrows,)
2017
# check the 10 first elements
2018
assert allequal(array[:10], arange(10, type='Int8'))
2019
# check the 10 last elements
2020
stop = self.narows%256
2024
assert allequal(array[-10:], arange(start, stop, type='Int8'))
2027
class Rows64bitsTestCase1(Rows64bitsTestCase):
2030
class Rows64bitsTestCase2(Rows64bitsTestCase):
2033
#----------------------------------------------------------------------
2037
theSuite = unittest.TestSuite()
2040
#heavy = 1 # uncomment this only for testing purposes
2042
#theSuite.addTest(unittest.makeSuite(BasicTestCase))
2043
for n in range(niter):
2044
theSuite.addTest(unittest.makeSuite(BasicWriteTestCase))
2045
theSuite.addTest(unittest.makeSuite(BasicWrite2TestCase))
2046
theSuite.addTest(unittest.makeSuite(EmptyCArrayTestCase))
2047
theSuite.addTest(unittest.makeSuite(EmptyCArray2TestCase))
2048
theSuite.addTest(unittest.makeSuite(SlicesCArrayTestCase))
2049
theSuite.addTest(unittest.makeSuite(Slices2CArrayTestCase))
2050
theSuite.addTest(unittest.makeSuite(EllipsisCArrayTestCase))
2051
theSuite.addTest(unittest.makeSuite(Ellipsis2CArrayTestCase))
2052
theSuite.addTest(unittest.makeSuite(Ellipsis3CArrayTestCase))
2053
theSuite.addTest(unittest.makeSuite(ZlibComprTestCase))
2054
theSuite.addTest(unittest.makeSuite(ZlibShuffleTestCase))
2055
theSuite.addTest(unittest.makeSuite(LZOComprTestCase))
2056
theSuite.addTest(unittest.makeSuite(LZOShuffleTestCase))
2057
theSuite.addTest(unittest.makeSuite(BZIP2ComprTestCase))
2058
theSuite.addTest(unittest.makeSuite(BZIP2ShuffleTestCase))
2059
theSuite.addTest(unittest.makeSuite(FloatTypeTestCase))
2060
theSuite.addTest(unittest.makeSuite(ComplexTypeTestCase))
2061
theSuite.addTest(unittest.makeSuite(CharTypeTestCase))
2062
theSuite.addTest(unittest.makeSuite(CharType2TestCase))
2063
theSuite.addTest(unittest.makeSuite(CharTypeComprTestCase))
2065
theSuite.addTest(unittest.makeSuite(NumpyInt8TestCase))
2066
theSuite.addTest(unittest.makeSuite(NumpyInt16TestCase))
2067
theSuite.addTest(unittest.makeSuite(NumpyInt32TestCase))
2068
theSuite.addTest(unittest.makeSuite(NumpyFloat32TestCase))
2069
theSuite.addTest(unittest.makeSuite(NumpyFloat64TestCase))
2070
theSuite.addTest(unittest.makeSuite(NumpyComplex32TestCase))
2071
theSuite.addTest(unittest.makeSuite(NumpyComplex64TestCase))
2072
theSuite.addTest(unittest.makeSuite(NumpyComprTestCase))
2073
theSuite.addTest(unittest.makeSuite(NumpyOffsetStrideTestCase))
2075
theSuite.addTest(unittest.makeSuite(NumericInt8TestCase))
2076
theSuite.addTest(unittest.makeSuite(NumericInt16TestCase))
2077
theSuite.addTest(unittest.makeSuite(NumericInt32TestCase))
2078
theSuite.addTest(unittest.makeSuite(NumericFloat32TestCase))
2079
theSuite.addTest(unittest.makeSuite(NumericFloat64TestCase))
2080
theSuite.addTest(unittest.makeSuite(NumericComplex32TestCase))
2081
theSuite.addTest(unittest.makeSuite(NumericComplex64TestCase))
2082
theSuite.addTest(unittest.makeSuite(NumericComprTestCase))
2083
theSuite.addTest(unittest.makeSuite(NumericOffsetStrideTestCase))
2085
theSuite.addTest(unittest.makeSuite(OffsetStrideTestCase))
2086
theSuite.addTest(unittest.makeSuite(Fletcher32TestCase))
2087
theSuite.addTest(unittest.makeSuite(AllFiltersTestCase))
2088
theSuite.addTest(unittest.makeSuite(CloseCopyTestCase))
2089
theSuite.addTest(unittest.makeSuite(OpenCopyTestCase))
2090
theSuite.addTest(unittest.makeSuite(CopyIndex1TestCase))
2091
theSuite.addTest(unittest.makeSuite(CopyIndex2TestCase))
2092
theSuite.addTest(unittest.makeSuite(CopyIndex3TestCase))
2093
theSuite.addTest(unittest.makeSuite(CopyIndex4TestCase))
2094
theSuite.addTest(unittest.makeSuite(CopyIndex5TestCase))
2096
theSuite.addTest(unittest.makeSuite(Slices3CArrayTestCase))
2097
theSuite.addTest(unittest.makeSuite(Slices4CArrayTestCase))
2098
theSuite.addTest(unittest.makeSuite(Ellipsis4CArrayTestCase))
2099
theSuite.addTest(unittest.makeSuite(Ellipsis5CArrayTestCase))
2100
theSuite.addTest(unittest.makeSuite(Ellipsis6CArrayTestCase))
2101
theSuite.addTest(unittest.makeSuite(Ellipsis7CArrayTestCase))
2102
theSuite.addTest(unittest.makeSuite(MD3WriteTestCase))
2103
theSuite.addTest(unittest.makeSuite(MD5WriteTestCase))
2104
theSuite.addTest(unittest.makeSuite(MD6WriteTestCase))
2105
theSuite.addTest(unittest.makeSuite(MD7WriteTestCase))
2106
theSuite.addTest(unittest.makeSuite(MD10WriteTestCase))
2107
theSuite.addTest(unittest.makeSuite(CopyIndex6TestCase))
2108
theSuite.addTest(unittest.makeSuite(CopyIndex7TestCase))
2109
theSuite.addTest(unittest.makeSuite(CopyIndex8TestCase))
2110
theSuite.addTest(unittest.makeSuite(CopyIndex9TestCase))
2111
theSuite.addTest(unittest.makeSuite(CopyIndex10TestCase))
2112
theSuite.addTest(unittest.makeSuite(CopyIndex11TestCase))
2113
theSuite.addTest(unittest.makeSuite(CopyIndex12TestCase))
2114
theSuite.addTest(unittest.makeSuite(Rows64bitsTestCase1))
2115
theSuite.addTest(unittest.makeSuite(Rows64bitsTestCase2))
2119
if __name__ == '__main__':
2120
unittest.main( defaultTest='suite' )
2124
## py-indent-offset: 4