<s> from __future__ import print_function <EOL> from __future__ import absolute_import <EOL> import os <EOL> import sys <EOL> import tempfile <EOL> import numpy as np <EOL> import tables <EOL> from tables import ( <EOL> StringCol , BoolCol , FloatCol , ComplexCol , EnumCol , <EOL> Int8Col , UInt8Col , Int16Col , UInt16Col , Int32Col , UInt32Col , <EOL> Int64Col , Float32Col , Float64Col , Time64Col <EOL> ) <EOL> from tables . tests import common <EOL> from tables . tests . common import allequal <EOL> from tables . tests . common import unittest <EOL> from tables . tests . common import PyTablesTestCase as TestCase <EOL> from six . moves import range <EOL> typecodes = [ '<STR_LIT:b>' , '<STR_LIT:h>' , '<STR_LIT:i>' , '<STR_LIT:l>' , '<STR_LIT:q>' , '<STR_LIT:f>' , '<STR_LIT:d>' ] <EOL> if sys . platform != '<STR_LIT:win32>' : <EOL> typecodes += [ '<STR_LIT:B>' , '<STR_LIT:H>' , '<STR_LIT:I>' , '<STR_LIT:L>' , '<STR_LIT>' , '<STR_LIT:F>' , '<STR_LIT:D>' ] <EOL> else : <EOL> typecodes += [ '<STR_LIT:B>' , '<STR_LIT:H>' , '<STR_LIT:I>' , '<STR_LIT:L>' , '<STR_LIT:F>' , '<STR_LIT:D>' ] <EOL> typecodes += [ '<STR_LIT>' ] <EOL> if hasattr ( tables , '<STR_LIT>' ) : <EOL> typecodes . append ( '<STR_LIT:e>' ) <EOL> if hasattr ( tables , '<STR_LIT>' ) or hasattr ( tables , '<STR_LIT>' ) : <EOL> typecodes . append ( '<STR_LIT:g>' ) <EOL> if hasattr ( tables , '<STR_LIT>' ) or hasattr ( tables , '<STR_LIT>' ) : <EOL> typecodes . append ( '<STR_LIT>' ) <EOL> byteorder = { '<STR_LIT>' : '<STR_LIT:<>' , '<STR_LIT>' : '<STR_LIT:>>' } [ sys . byteorder ] <EOL> class BasicTestCase ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> endiancheck = <NUM_LIT:0> <EOL> def WriteRead ( self , testArray ) : <EOL> if common . verbose : <EOL> print ( '<STR_LIT:\n>' , '<STR_LIT>' * <NUM_LIT:30> ) <EOL> print ( "<STR_LIT>" % <EOL> testArray . dtype . char , end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" , self . title ) <EOL> self . h5fname = tempfile . mktemp ( "<STR_LIT>" ) <EOL> try : <EOL> with tables . open_file ( self . h5fname , mode = "<STR_LIT:w>" ) as self . h5file : <EOL> self . root = self . h5file . root <EOL> a = testArray <EOL> self . h5file . create_array ( self . root , '<STR_LIT>' , a , <EOL> "<STR_LIT>" ) <EOL> with tables . open_file ( self . h5fname , mode = "<STR_LIT:r>" ) as self . h5file : <EOL> self . root = self . h5file . root <EOL> b = self . root . somearray . read ( ) <EOL> if not hasattr ( b , "<STR_LIT>" ) : <EOL> b = np . np . array ( b , dtype = a . dtype . str ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , a ) <EOL> print ( "<STR_LIT>" , a . shape ) <EOL> print ( "<STR_LIT>" , a . itemsize ) <EOL> print ( "<STR_LIT>" , a . dtype . char ) <EOL> print ( "<STR_LIT>" , b ) <EOL> print ( "<STR_LIT>" , b . shape ) <EOL> print ( "<STR_LIT>" , b . itemsize ) <EOL> print ( "<STR_LIT>" , b . dtype . char ) <EOL> type_ = self . root . somearray . atom . type <EOL> self . assertEqual ( type ( a ) , type ( b ) ) <EOL> self . assertEqual ( a . shape , b . shape ) <EOL> self . assertEqual ( a . shape , self . root . somearray . shape ) <EOL> self . assertEqual ( a . dtype , b . dtype ) <EOL> if a . dtype . char [ <NUM_LIT:0> ] == "<STR_LIT:S>" : <EOL> self . assertEqual ( type_ , "<STR_LIT:string>" ) <EOL> else : <EOL> self . assertEqual ( a . dtype . base . name , type_ ) <EOL> self . assertTrue ( allequal ( a , b , "<STR_LIT>" ) ) <EOL> finally : <EOL> if os . path . exists ( self . h5fname ) : <EOL> os . remove ( self . h5fname ) <EOL> def test00_char ( self ) : <EOL> """<STR_LIT>""" <EOL> a = np . array ( self . tupleChar , '<STR_LIT:S>' + str ( len ( self . tupleChar ) ) ) <EOL> self . WriteRead ( a ) <EOL> def test01_char_nc ( self ) : <EOL> """<STR_LIT>""" <EOL> a = np . array ( self . tupleChar , '<STR_LIT:S>' + str ( len ( self . tupleChar ) ) ) <EOL> if a . shape == ( ) : <EOL> b = a <EOL> else : <EOL> b = a [ : : <NUM_LIT:2> ] <EOL> if a . shape [ <NUM_LIT:0> ] > <NUM_LIT:2> : <EOL> self . assertEqual ( b . flags [ '<STR_LIT>' ] , False ) <EOL> self . WriteRead ( b ) <EOL> def test02_types ( self ) : <EOL> """<STR_LIT>""" <EOL> for typecode in typecodes : <EOL> if self . tupleInt . shape : <EOL> a = self . tupleInt . astype ( typecode ) <EOL> else : <EOL> a = np . array ( self . tupleInt , dtype = typecode ) <EOL> self . WriteRead ( a ) <EOL> def test03_types_nc ( self ) : <EOL> """<STR_LIT>""" <EOL> for typecode in typecodes : <EOL> if self . tupleInt . shape : <EOL> a = self . tupleInt . astype ( typecode ) <EOL> else : <EOL> a = np . array ( self . tupleInt , dtype = typecode ) <EOL> if len ( a . shape ) == <NUM_LIT:0> : <EOL> raise unittest . SkipTest <EOL> b = a [ : : <NUM_LIT:2> ] <EOL> if a . shape [ <NUM_LIT:0> ] > <NUM_LIT:2> : <EOL> self . assertEqual ( b . flags [ '<STR_LIT>' ] , False ) <EOL> self . WriteRead ( b ) <EOL> class Basic0DOneTestCase ( BasicTestCase ) : <EOL> title = "<STR_LIT>" <EOL> tupleInt = np . array ( <NUM_LIT:3> ) <EOL> tupleChar = "<STR_LIT:4>" <EOL> class Basic0DTwoTestCase ( BasicTestCase ) : <EOL> title = "<STR_LIT>" <EOL> tupleInt = np . array ( <NUM_LIT> ) <EOL> tupleChar = "<STR_LIT>" <EOL> class Basic1DOneTestCase ( BasicTestCase ) : <EOL> title = "<STR_LIT>" <EOL> tupleInt = np . array ( ( <NUM_LIT:3> , ) ) <EOL> tupleChar = ( "<STR_LIT:a>" , ) <EOL> class Basic1DTwoTestCase ( BasicTestCase ) : <EOL> title = "<STR_LIT>" <EOL> tupleInt = np . array ( ( <NUM_LIT:0> , <NUM_LIT:4> ) ) <EOL> tupleChar = ( "<STR_LIT>" , ) <EOL> class Basic1DThreeTestCase ( BasicTestCase ) : <EOL> title = "<STR_LIT>" <EOL> tupleInt = np . array ( ( <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ) ) <EOL> tupleChar = ( "<STR_LIT>" , "<STR_LIT>" , ) <EOL> class Basic2DTestCase ( BasicTestCase ) : <EOL> title = "<STR_LIT>" <EOL> tupleInt = np . ones ( ( <NUM_LIT:4> , ) * <NUM_LIT:2> ) <EOL> tupleChar = [ [ "<STR_LIT>" , "<STR_LIT>" ] , [ "<STR_LIT:d>" , "<STR_LIT>" ] , [ "<STR_LIT:s>" , "<STR_LIT>" ] ] <EOL> class Basic10DTestCase ( BasicTestCase ) : <EOL> title = "<STR_LIT>" <EOL> tupleInt = np . ones ( ( <NUM_LIT:2> , ) * <NUM_LIT:10> ) <EOL> tupleChar = np . array ( tupleInt , dtype = "<STR_LIT>" ) <EOL> class GroupsArrayTestCase ( common . TempFileMixin , TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test00_iterativeGroups ( self ) : <EOL> """<STR_LIT>""" <EOL> if common . verbose : <EOL> print ( '<STR_LIT:\n>' , '<STR_LIT>' * <NUM_LIT:30> ) <EOL> print ( "<STR_LIT>" % <EOL> self . __class__ . __name__ ) <EOL> group = self . h5file . root <EOL> i = <NUM_LIT:1> <EOL> for typecode in typecodes : <EOL> a = np . ones ( ( <NUM_LIT:2> , ) * i , typecode ) <EOL> dsetname = '<STR_LIT>' + typecode <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , group . _g_join ( dsetname ) ) <EOL> self . h5file . create_array ( group , dsetname , a , "<STR_LIT>" ) <EOL> group = self . h5file . create_group ( group , '<STR_LIT>' + str ( i ) ) <EOL> i += <NUM_LIT:1> <EOL> self . _reopen ( ) <EOL> group = self . h5file . root <EOL> for i in range ( <NUM_LIT:1> , len ( typecodes ) ) : <EOL> a = np . ones ( ( <NUM_LIT:2> , ) * i , typecodes [ i - <NUM_LIT:1> ] ) <EOL> dset = getattr ( group , '<STR_LIT>' + typecodes [ i - <NUM_LIT:1> ] ) <EOL> b = dset . read ( ) <EOL> if not allequal ( a , b , "<STR_LIT>" ) and common . verbose : <EOL> print ( "<STR_LIT>" , a . shape ) <EOL> print ( "<STR_LIT>" , a ) <EOL> print ( "<STR_LIT>" , dset . _v_pathname ) <EOL> print ( "<STR_LIT>" , dset . shape , end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" % dset . dtype ) <EOL> print ( "<STR_LIT>" , b . shape , end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" % b . dtype . char ) <EOL> self . assertEqual ( a . shape , b . shape ) <EOL> if np . dtype ( '<STR_LIT:l>' ) . itemsize == <NUM_LIT:4> : <EOL> if ( a . dtype . char == "<STR_LIT:i>" or a . dtype . char == "<STR_LIT:l>" ) : <EOL> self . assertTrue ( b . dtype . char == "<STR_LIT:l>" or b . dtype . char == "<STR_LIT:i>" ) <EOL> elif ( a . dtype . char == "<STR_LIT:I>" or a . dtype . char == "<STR_LIT:L>" ) : <EOL> self . assertTrue ( b . dtype . char == "<STR_LIT:L>" or b . dtype . char == "<STR_LIT:I>" ) <EOL> else : <EOL> self . assertTrue ( allequal ( a , b , "<STR_LIT>" ) ) <EOL> elif np . dtype ( '<STR_LIT:l>' ) . itemsize == <NUM_LIT:8> : <EOL> if ( a . dtype . char == "<STR_LIT:q>" or a . dtype . char == "<STR_LIT:l>" ) : <EOL> self . assertTrue ( b . dtype . char == "<STR_LIT:l>" or b . dtype . char == "<STR_LIT:q>" ) <EOL> elif ( a . dtype . char == "<STR_LIT>" or a . dtype . char == "<STR_LIT:L>" ) : <EOL> self . assertTrue ( b . dtype . char == "<STR_LIT:L>" or b . dtype . char == "<STR_LIT>" ) <EOL> else : <EOL> self . assertTrue ( allequal ( a , b , "<STR_LIT>" ) ) <EOL> group = getattr ( group , '<STR_LIT>' + str ( i ) ) <EOL> def test01_largeRankArrays ( self ) : <EOL> """<STR_LIT>""" <EOL> minrank = <NUM_LIT:1> <EOL> maxrank = <NUM_LIT:32> <EOL> if common . verbose : <EOL> print ( '<STR_LIT:\n>' , '<STR_LIT>' * <NUM_LIT:30> ) <EOL> print ( "<STR_LIT>" % <EOL> self . __class__ . __name__ ) <EOL> print ( "<STR_LIT>" , maxrank ) <EOL> group = self . h5file . root <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , end = '<STR_LIT:U+0020>' ) <EOL> for rank in range ( minrank , maxrank + <NUM_LIT:1> ) : <EOL> a = np . ones ( ( <NUM_LIT:1> , ) * rank , '<STR_LIT:i>' ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" % ( rank ) , end = '<STR_LIT:U+0020>' ) <EOL> self . h5file . create_array ( group , "<STR_LIT>" , a , "<STR_LIT>" % rank ) <EOL> group = self . h5file . create_group ( group , '<STR_LIT>' + str ( rank ) ) <EOL> self . h5file . flush ( ) <EOL> self . _reopen ( ) <EOL> group = self . h5file . root <EOL> if common . verbose : <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> for rank in range ( minrank , maxrank + <NUM_LIT:1> ) : <EOL> a = np . ones ( ( <NUM_LIT:1> , ) * rank , '<STR_LIT:i>' ) <EOL> b = group . array . read ( ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" % ( rank ) , end = '<STR_LIT:U+0020>' ) <EOL> if not a . tolist ( ) == b . tolist ( ) and common . verbose : <EOL> dset = group . array <EOL> print ( "<STR_LIT>" , dset . _v_pathname ) <EOL> print ( "<STR_LIT>" , dset . shape , end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" % dset . typecode ) <EOL> print ( "<STR_LIT>" , b . shape , end = '<STR_LIT:U+0020>' ) <EOL> print ( "<STR_LIT>" % b . dtype . char ) <EOL> self . assertEqual ( a . shape , b . shape ) <EOL> if a . dtype . char == "<STR_LIT:i>" : <EOL> self . assertTrue ( b . dtype . char == "<STR_LIT:l>" or b . dtype . char == "<STR_LIT:i>" ) <EOL> else : <EOL> self . assertEqual ( a . dtype . char , b . dtype . char ) <EOL> self . assertEqual ( a , b ) <EOL> group = self . h5file . get_node ( group , '<STR_LIT>' + str ( rank ) ) <EOL> if common . verbose : <EOL> print ( ) <EOL> class Record ( tables . IsDescription ) : <EOL> var1 = StringCol ( itemsize = <NUM_LIT:4> , dflt = b"<STR_LIT>" , pos = <NUM_LIT:0> ) <EOL> var2 = StringCol ( itemsize = <NUM_LIT:1> , dflt = b"<STR_LIT:a>" , pos = <NUM_LIT:1> ) <EOL> var3 = BoolCol ( dflt = <NUM_LIT:1> ) <EOL> var4 = Int8Col ( dflt = <NUM_LIT:1> ) <EOL> var5 = UInt8Col ( dflt = <NUM_LIT:1> ) <EOL> var6 = Int16Col ( dflt = <NUM_LIT:1> ) <EOL> var7 = UInt16Col ( dflt = <NUM_LIT:1> ) <EOL> var8 = Int32Col ( dflt = <NUM_LIT:1> ) <EOL> var9 = UInt32Col ( dflt = <NUM_LIT:1> ) <EOL> var10 = Int64Col ( dflt = <NUM_LIT:1> ) <EOL> var11 = Float32Col ( dflt = <NUM_LIT:1.0> ) <EOL> var12 = Float64Col ( dflt = <NUM_LIT:1.0> ) <EOL> var13 = ComplexCol ( itemsize = <NUM_LIT:8> , dflt = ( <NUM_LIT:1.> + <NUM_LIT> ) ) <EOL> var14 = ComplexCol ( itemsize = <NUM_LIT:16> , dflt = ( <NUM_LIT:1.> + <NUM_LIT> ) ) <EOL> if hasattr ( tables , '<STR_LIT>' ) : <EOL> var15 = tables . Float16Col ( dflt = <NUM_LIT:1.0> ) <EOL> if hasattr ( tables , '<STR_LIT>' ) : <EOL> var16 = tables . Float96Col ( dflt = <NUM_LIT:1.0> ) <EOL> if hasattr ( tables , '<STR_LIT>' ) : <EOL> var17 = tables . Float128Col ( dflt = <NUM_LIT:1.0> ) <EOL> if hasattr ( tables , '<STR_LIT>' ) : <EOL> var18 = tables . ComplexCol ( itemsize = <NUM_LIT> , dflt = ( <NUM_LIT:1.> + <NUM_LIT> ) ) <EOL> if hasattr ( tables , '<STR_LIT>' ) : <EOL> var19 = tables . ComplexCol ( itemsize = <NUM_LIT:32> , dflt = ( <NUM_LIT:1.> + <NUM_LIT> ) ) <EOL> class TableReadTestCase ( common . TempFileMixin , TestCase ) : <EOL> nrows = <NUM_LIT:100> <EOL> def setUp ( self ) : <EOL> super ( TableReadTestCase , self ) . setUp ( ) <EOL> table = self . h5file . create_table ( self . h5file . root , '<STR_LIT>' , Record ) <EOL> for i in range ( self . nrows ) : <EOL> table . row . append ( ) <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> def test01_readTableChar ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> table . flavor = "<STR_LIT>" <EOL> for colname in table . colnames : <EOL> numcol = table . read ( field = colname ) <EOL> typecol = table . coltypes [ colname ] <EOL> itemsizecol = table . description . _v_dtypes [ colname ] . base . itemsize <EOL> nctypecode = numcol . dtype . char <EOL> if typecol == "<STR_LIT:string>" : <EOL> if itemsizecol > <NUM_LIT:1> : <EOL> orignumcol = np . array ( [ '<STR_LIT>' ] * self . nrows , dtype = '<STR_LIT>' ) <EOL> else : <EOL> orignumcol = np . array ( [ '<STR_LIT:a>' ] * self . nrows , dtype = '<STR_LIT>' ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , nctypecode ) <EOL> print ( "<STR_LIT>" , '<STR_LIT:c>' ) <EOL> print ( "<STR_LIT>" , itemsizecol ) <EOL> print ( "<STR_LIT>" , numcol . shape ) <EOL> print ( "<STR_LIT>" , orignumcol . shape ) <EOL> print ( "<STR_LIT>" , numcol [ : <NUM_LIT:3> ] ) <EOL> self . assertTrue ( allequal ( numcol , orignumcol , "<STR_LIT>" ) ) <EOL> def test01_readTableNum ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> table . flavor = "<STR_LIT>" <EOL> for colname in table . colnames : <EOL> numcol = table . read ( field = colname ) <EOL> typecol = table . coltypes [ colname ] <EOL> nctypecode = np . typeNA [ numcol . dtype . char [ <NUM_LIT:0> ] ] <EOL> if typecol != "<STR_LIT:string>" : <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , nctypecode ) <EOL> print ( "<STR_LIT>" , typecol ) <EOL> orignumcol = np . ones ( shape = self . nrows , dtype = numcol . dtype . char ) <EOL> self . assertTrue ( allequal ( numcol , orignumcol , "<STR_LIT>" ) ) <EOL> def test02_readCoordsChar ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> table . flavor = "<STR_LIT>" <EOL> coords = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> self . nrows = len ( coords ) <EOL> for colname in table . colnames : <EOL> numcol = table . read_coordinates ( coords , field = colname ) <EOL> typecol = table . coltypes [ colname ] <EOL> itemsizecol = table . description . _v_dtypes [ colname ] . base . itemsize <EOL> nctypecode = numcol . dtype . char <EOL> if typecol == "<STR_LIT:string>" : <EOL> if itemsizecol > <NUM_LIT:1> : <EOL> orignumcol = np . array ( [ '<STR_LIT>' ] * self . nrows , dtype = '<STR_LIT>' ) <EOL> else : <EOL> orignumcol = np . array ( [ '<STR_LIT:a>' ] * self . nrows , dtype = '<STR_LIT>' ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , nctypecode ) <EOL> print ( "<STR_LIT>" , '<STR_LIT:c>' ) <EOL> print ( "<STR_LIT>" , itemsizecol ) <EOL> print ( "<STR_LIT>" , numcol . shape ) <EOL> print ( "<STR_LIT>" , orignumcol . shape ) <EOL> print ( "<STR_LIT>" , numcol [ : <NUM_LIT:3> ] ) <EOL> self . assertTrue ( allequal ( numcol , orignumcol , "<STR_LIT>" ) ) <EOL> def test02_readCoordsNum ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> table . flavor = "<STR_LIT>" <EOL> coords = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> self . nrows = len ( coords ) <EOL> for colname in table . colnames : <EOL> numcol = table . read_coordinates ( coords , field = colname ) <EOL> typecol = table . coltypes [ colname ] <EOL> type_ = numcol . dtype . type <EOL> if typecol != "<STR_LIT:string>" : <EOL> if typecol == "<STR_LIT>" : <EOL> return <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type_ ) <EOL> print ( "<STR_LIT>" , typecol ) <EOL> orignumcol = np . ones ( shape = self . nrows , dtype = numcol . dtype . char ) <EOL> self . assertTrue ( allequal ( numcol , orignumcol , "<STR_LIT>" ) ) <EOL> def test03_getIndexNumPy ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> coords = np . array ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , dtype = '<STR_LIT>' ) <EOL> for colname in table . colnames : <EOL> numcol = [ table [ coord ] [ colname ] for coord in coords ] <EOL> typecol = table . coltypes [ colname ] <EOL> if typecol != "<STR_LIT:string>" : <EOL> if typecol == "<STR_LIT>" : <EOL> return <EOL> numcol = np . array ( numcol , typecol ) <EOL> if common . verbose : <EOL> type_ = numcol . dtype . type <EOL> print ( "<STR_LIT>" , type_ ) <EOL> print ( "<STR_LIT>" , typecol ) <EOL> orignumcol = np . ones ( shape = len ( numcol ) , <EOL> dtype = numcol . dtype . char ) <EOL> self . assertTrue ( allequal ( numcol , orignumcol , "<STR_LIT>" ) ) <EOL> def test04_setIndexNumPy ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> table . flavor = "<STR_LIT>" <EOL> coords = np . array ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , dtype = '<STR_LIT>' ) <EOL> n = len ( Record . columns ) - <NUM_LIT:2> <EOL> table [ coords [ <NUM_LIT:0> ] ] = tuple ( [ "<STR_LIT>" , "<STR_LIT:x>" ] + [ <NUM_LIT> ] * n ) <EOL> record = table . read ( coords [ <NUM_LIT:0> ] , coords [ <NUM_LIT:0> ] + <NUM_LIT:1> ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" , record ) <EOL> self . assertEqual ( record [ '<STR_LIT>' ] , b'<STR_LIT>' ) <EOL> self . assertEqual ( record [ '<STR_LIT>' ] , b'<STR_LIT:x>' ) <EOL> self . assertEqual ( record [ '<STR_LIT>' ] , True ) <EOL> self . assertEqual ( record [ '<STR_LIT>' ] , - <NUM_LIT> ) <EOL> self . assertEqual ( record [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> class Info ( tables . IsDescription ) : <EOL> _v_pos = <NUM_LIT:3> <EOL> Name = StringCol ( itemsize = <NUM_LIT:2> ) <EOL> Value = ComplexCol ( itemsize = <NUM_LIT:16> ) <EOL> class TestTDescr ( tables . IsDescription ) : <EOL> """<STR_LIT>""" <EOL> x = Int32Col ( dflt = <NUM_LIT:0> , shape = <NUM_LIT:2> , pos = <NUM_LIT:0> ) <EOL> y = FloatCol ( dflt = <NUM_LIT:1> , shape = ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> z = UInt8Col ( dflt = <NUM_LIT:1> ) <EOL> z3 = EnumCol ( { '<STR_LIT:r>' : <NUM_LIT:4> , '<STR_LIT:g>' : <NUM_LIT:2> , '<STR_LIT:b>' : <NUM_LIT:1> } , '<STR_LIT:r>' , '<STR_LIT>' , shape = <NUM_LIT:2> ) <EOL> color = StringCol ( itemsize = <NUM_LIT:4> , dflt = b"<STR_LIT>" , pos = <NUM_LIT:2> ) <EOL> info = Info ( ) <EOL> class Info ( tables . IsDescription ) : <EOL> _v_pos = <NUM_LIT:1> <EOL> name = StringCol ( itemsize = <NUM_LIT:2> ) <EOL> value = ComplexCol ( itemsize = <NUM_LIT:16> , pos = <NUM_LIT:0> ) <EOL> y2 = FloatCol ( pos = <NUM_LIT:1> ) <EOL> z2 = UInt8Col ( ) <EOL> class Info2 ( tables . IsDescription ) : <EOL> y3 = Time64Col ( shape = <NUM_LIT:2> ) <EOL> name = StringCol ( itemsize = <NUM_LIT:2> ) <EOL> value = ComplexCol ( itemsize = <NUM_LIT:16> , shape = <NUM_LIT:2> ) <EOL> class TableNativeFlavorTestCase ( common . TempFileMixin , TestCase ) : <EOL> nrows = <NUM_LIT:100> <EOL> def setUp ( self ) : <EOL> super ( TableNativeFlavorTestCase , self ) . setUp ( ) <EOL> table = self . h5file . create_table ( self . h5file . root , '<STR_LIT>' , TestTDescr , <EOL> expectedrows = self . nrows ) <EOL> table . flavor = "<STR_LIT>" <EOL> for i in range ( self . nrows ) : <EOL> table . row . append ( ) <EOL> table . flush ( ) <EOL> def test01a_basicTableRead ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table [ : ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> col = table . cols . x [ : <NUM_LIT:3> ] <EOL> self . assertTrue ( isinstance ( col , np . ndarray ) ) <EOL> npcol = np . zeros ( ( <NUM_LIT:3> , <NUM_LIT:2> ) , dtype = "<STR_LIT>" ) <EOL> self . assertTrue ( allequal ( col , npcol , "<STR_LIT>" ) ) <EOL> col = table . cols . Info [ : <NUM_LIT:3> ] <EOL> self . assertTrue ( isinstance ( col , np . ndarray ) ) <EOL> dtype = [ ( '<STR_LIT:value>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' , ( <NUM_LIT:2> , ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , ( <NUM_LIT:2> , ) ) ] ) , <EOL> ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> npcol = np . zeros ( ( <NUM_LIT:3> , ) , dtype = dtype ) <EOL> self . assertEqual ( col . dtype . descr , npcol . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , col ) <EOL> print ( "<STR_LIT>" , npcol ) <EOL> self . assertEqual ( bytes ( col . copy ( ) . data ) , bytes ( npcol . data ) ) <EOL> def test01b_basicTableRead ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table [ : : <NUM_LIT:3> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> col = table . cols . x [ : <NUM_LIT:9> : <NUM_LIT:3> ] <EOL> self . assertTrue ( isinstance ( col , np . ndarray ) ) <EOL> npcol = np . zeros ( ( <NUM_LIT:3> , <NUM_LIT:2> ) , dtype = "<STR_LIT>" ) <EOL> self . assertTrue ( allequal ( col , npcol , "<STR_LIT>" ) ) <EOL> col = table . cols . Info [ : <NUM_LIT:9> : <NUM_LIT:3> ] <EOL> self . assertTrue ( isinstance ( col , np . ndarray ) ) <EOL> dtype = [ ( '<STR_LIT:value>' , '<STR_LIT>' % byteorder ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' % byteorder ) , <EOL> ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' % byteorder , ( <NUM_LIT:2> , ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' % byteorder , ( <NUM_LIT:2> , ) ) ] ) , <EOL> ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> npcol = np . zeros ( ( <NUM_LIT:3> , ) , dtype = dtype ) <EOL> self . assertEqual ( col . dtype . descr , npcol . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , col ) <EOL> print ( "<STR_LIT>" , npcol ) <EOL> self . assertEqual ( bytes ( col . copy ( ) . data ) , bytes ( npcol . data ) ) <EOL> def test02_getWhereList ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table . get_where_list ( '<STR_LIT>' ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:100> ) <EOL> self . assertTrue ( allequal ( data , np . arange ( <NUM_LIT:100> , dtype = "<STR_LIT>" ) , "<STR_LIT>" ) ) <EOL> def test03a_readWhere ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> table . cols . color . create_index ( ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table . read_where ( '<STR_LIT>' ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( len ( data ) , self . nrows ) <EOL> def test03b_readWhere ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> table . cols . z . create_index ( ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table . read_where ( '<STR_LIT>' ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:0> ) <EOL> def test04a_createTable ( self ) : <EOL> """<STR_LIT>""" <EOL> dtype = [ ( '<STR_LIT:value>' , '<STR_LIT>' % byteorder ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' % byteorder ) , <EOL> ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' % byteorder , ( <NUM_LIT:2> , ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' % byteorder , ( <NUM_LIT:2> , ) ) ] ) , <EOL> ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> npdata = np . zeros ( ( <NUM_LIT:3> , ) , dtype = dtype ) <EOL> table = self . h5file . create_table ( self . h5file . root , '<STR_LIT>' , npdata ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table2 <EOL> data = table [ : ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , npdata . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , npdata ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertEqual ( bytes ( data . copy ( ) . data ) , bytes ( npdata . data ) ) <EOL> def test04b_appendTable ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> npdata = table [ <NUM_LIT:3> : <NUM_LIT:6> ] <EOL> table . append ( npdata ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table [ - <NUM_LIT:3> : ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ - <NUM_LIT:3> : ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , npdata . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , npdata ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertEqual ( bytes ( data . copy ( ) . data ) , bytes ( npdata . data ) ) <EOL> def test05a_assignColumn ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> table . cols . z [ : ] = np . zeros ( ( <NUM_LIT:100> , ) , dtype = '<STR_LIT>' ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table . cols . z [ : ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:100> ) <EOL> self . assertTrue ( allequal ( data , np . zeros ( ( <NUM_LIT:100> , ) , dtype = "<STR_LIT>" ) , "<STR_LIT>" ) ) <EOL> def test05b_modifyingColumns ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> xcol = np . ones ( ( <NUM_LIT:3> , <NUM_LIT:2> ) , '<STR_LIT>' ) <EOL> ycol = np . zeros ( ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:2> ) , '<STR_LIT>' ) <EOL> zcol = np . zeros ( ( <NUM_LIT:3> , ) , '<STR_LIT>' ) <EOL> table . modify_columns ( <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , [ xcol , ycol , zcol ] , [ '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT:z>' ] ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table . cols . y [ <NUM_LIT:3> : <NUM_LIT:6> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , ycol . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , ycol ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertEqual ( data . copy ( ) . data , ycol . data ) <EOL> def test05c_modifyingColumns ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> dtype = [ ( '<STR_LIT:x>' , '<STR_LIT>' , ( <NUM_LIT:2> , ) ) , ( '<STR_LIT:y>' , '<STR_LIT>' , ( <NUM_LIT:2> , <NUM_LIT:2> ) ) , ( '<STR_LIT:z>' , '<STR_LIT>' ) ] <EOL> nparray = np . zeros ( ( <NUM_LIT:3> , ) , dtype = dtype ) <EOL> table . modify_columns ( <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , nparray , [ '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT:z>' ] ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> ycol = np . zeros ( ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:2> ) , '<STR_LIT>' ) <EOL> data = table . cols . y [ <NUM_LIT:3> : <NUM_LIT:6> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , ycol . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , ycol ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertEqual ( data . copy ( ) . data , ycol . data ) <EOL> def test06a_assignNestedColumn ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> dtype = [ ( '<STR_LIT:value>' , '<STR_LIT>' % byteorder ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' % byteorder ) , <EOL> ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' % byteorder , ( <NUM_LIT:2> , ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' % byteorder , ( <NUM_LIT:2> , ) ) ] ) , <EOL> ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> npdata = np . zeros ( ( <NUM_LIT:3> , ) , dtype = dtype ) <EOL> data = table . cols . Info [ <NUM_LIT:3> : <NUM_LIT:6> ] <EOL> table . modify_column ( <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , column = npdata , colname = '<STR_LIT>' ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table . cols . Info [ <NUM_LIT:3> : <NUM_LIT:6> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , npdata . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , npdata ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertEqual ( bytes ( data . copy ( ) . data ) , bytes ( npdata . data ) ) <EOL> def test06b_assignNestedColumn ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> dtype = [ ( '<STR_LIT:value>' , '<STR_LIT>' % byteorder ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' % byteorder ) , <EOL> ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:value>' , '<STR_LIT>' % byteorder , ( <NUM_LIT:2> , ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' % byteorder , ( <NUM_LIT:2> , ) ) ] ) , <EOL> ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> npdata = np . zeros ( ( <NUM_LIT:3> , ) , dtype = dtype ) <EOL> table . cols . Info [ <NUM_LIT:3> : <NUM_LIT:6> ] = npdata <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> data = table . cols . Info [ <NUM_LIT:3> : <NUM_LIT:6> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , npdata . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , npdata ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertEqual ( bytes ( data . copy ( ) . data ) , bytes ( npdata . data ) ) <EOL> def test07a_modifyingRows ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> chunk = table [ <NUM_LIT:0> : <NUM_LIT:3> ] <EOL> chunk [ '<STR_LIT:y>' ] [ : ] = - <NUM_LIT:1> <EOL> table . modify_rows ( <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT:1> , rows = chunk ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> ycol = np . zeros ( ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:2> ) , '<STR_LIT>' ) - <NUM_LIT:1> <EOL> data = table . cols . y [ <NUM_LIT:3> : <NUM_LIT:6> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , ycol . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , ycol ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertTrue ( allequal ( ycol , data , "<STR_LIT>" ) ) <EOL> def test07b_modifyingRows ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> chunk = table [ <NUM_LIT:0> : <NUM_LIT:3> ] <EOL> chunk [ '<STR_LIT:y>' ] [ : ] = - <NUM_LIT:1> <EOL> table . cols [ <NUM_LIT:3> : <NUM_LIT:6> ] = chunk <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> ycol = np . zeros ( ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:2> ) , '<STR_LIT>' ) - <NUM_LIT:1> <EOL> data = table . cols . y [ <NUM_LIT:3> : <NUM_LIT:6> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , ycol . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , ycol ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertTrue ( allequal ( ycol , data , "<STR_LIT>" ) ) <EOL> def test08a_modifyingRows ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> chunk = table [ <NUM_LIT:3> : <NUM_LIT:4> ] <EOL> chunk [ '<STR_LIT:y>' ] [ : ] = - <NUM_LIT:1> <EOL> table . modify_rows ( <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:1> , chunk ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> ycol = np . zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , '<STR_LIT>' ) - <NUM_LIT:1> <EOL> data = table . cols . y [ <NUM_LIT:6> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , ycol . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , ycol ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertTrue ( allequal ( ycol , data , "<STR_LIT>" ) ) <EOL> def test08b_modifyingRows ( self ) : <EOL> """<STR_LIT>""" <EOL> table = self . h5file . root . table <EOL> chunk = table [ <NUM_LIT:3> : <NUM_LIT:4> ] <EOL> chunk [ '<STR_LIT:y>' ] [ : ] = - <NUM_LIT:1> <EOL> table . cols [ <NUM_LIT:6> ] = chunk <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> ycol = np . zeros ( ( <NUM_LIT:2> , <NUM_LIT:2> ) , '<STR_LIT>' ) - <NUM_LIT:1> <EOL> data = table . cols . y [ <NUM_LIT:6> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> print ( "<STR_LIT>" , len ( data ) ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , ycol . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , ycol ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertTrue ( allequal ( ycol , data , "<STR_LIT>" ) ) <EOL> def test09a_getStrings ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> rdata = table . get_where_list ( '<STR_LIT>' ) <EOL> data = table . read_coordinates ( rdata ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:100> ) <EOL> for idata in data [ '<STR_LIT>' ] : <EOL> self . assertEqual ( idata , np . array ( "<STR_LIT>" , dtype = "<STR_LIT>" ) ) <EOL> def test09b_getStrings ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> for i in range ( <NUM_LIT:50> ) : <EOL> table . cols . color [ i ] = "<STR_LIT>" <EOL> table . flush ( ) <EOL> data = table [ : ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( len ( data ) , <NUM_LIT:100> ) <EOL> for i in range ( <NUM_LIT:100> ) : <EOL> idata = data [ '<STR_LIT>' ] [ i ] <EOL> if i >= <NUM_LIT:50> : <EOL> self . assertEqual ( idata , np . array ( "<STR_LIT>" , dtype = "<STR_LIT>" ) ) <EOL> else : <EOL> self . assertEqual ( idata , np . array ( "<STR_LIT>" , dtype = "<STR_LIT>" ) ) <EOL> def test09c_getStrings ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> table = self . h5file . root . table <EOL> row = table . row <EOL> for i in range ( <NUM_LIT:50> ) : <EOL> row [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> row . append ( ) <EOL> table . flush ( ) <EOL> if self . close : <EOL> self . h5file . close ( ) <EOL> self . h5file = tables . open_file ( self . h5fname , "<STR_LIT:a>" ) <EOL> data = self . h5file . root . table [ : ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , type ( data ) ) <EOL> print ( "<STR_LIT>" , data . dtype . descr ) <EOL> print ( "<STR_LIT>" , data [ : <NUM_LIT:3> ] ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( len ( data ) , <NUM_LIT> ) <EOL> for i in range ( <NUM_LIT> ) : <EOL> idata = data [ '<STR_LIT>' ] [ i ] <EOL> if i < <NUM_LIT:100> : <EOL> self . assertEqual ( idata , np . array ( "<STR_LIT>" , dtype = "<STR_LIT>" ) ) <EOL> else : <EOL> self . assertEqual ( idata , np . array ( "<STR_LIT>" , dtype = "<STR_LIT>" ) ) <EOL> class TableNativeFlavorOpenTestCase ( TableNativeFlavorTestCase ) : <EOL> close = <NUM_LIT:0> <EOL> class TableNativeFlavorCloseTestCase ( TableNativeFlavorTestCase ) : <EOL> close = <NUM_LIT:1> <EOL> class AttributesTestCase ( common . TempFileMixin , TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( AttributesTestCase , self ) . setUp ( ) <EOL> self . h5file . create_group ( self . h5file . root , '<STR_LIT>' ) <EOL> def test01_writeAttribute ( self ) : <EOL> """<STR_LIT>""" <EOL> group = self . h5file . root . group <EOL> g_attrs = group . _v_attrs <EOL> g_attrs . numpy1 = np . zeros ( ( <NUM_LIT:1> , <NUM_LIT:1> ) , dtype = '<STR_LIT>' ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> group = self . h5file . root . group <EOL> g_attrs = group . _v_attrs <EOL> data = g_attrs . numpy1 <EOL> npcomp = np . zeros ( ( <NUM_LIT:1> , <NUM_LIT:1> ) , dtype = '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , npcomp . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , npcomp ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertTrue ( allequal ( npcomp , data , "<STR_LIT>" ) ) <EOL> def test02_updateAttribute ( self ) : <EOL> """<STR_LIT>""" <EOL> group = self . h5file . root . group <EOL> g_attrs = group . _v_attrs <EOL> g_attrs . numpy1 = np . zeros ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , dtype = '<STR_LIT>' ) <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> group = self . h5file . root . group <EOL> g_attrs = group . _v_attrs <EOL> g_attrs . numpy1 = np . ones ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , dtype = '<STR_LIT>' ) <EOL> data = g_attrs . numpy1 <EOL> npcomp = np . ones ( ( <NUM_LIT:1> , <NUM_LIT:2> ) , dtype = '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( data , np . ndarray ) ) <EOL> self . assertEqual ( data . dtype . descr , npcomp . dtype . descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , npcomp ) <EOL> print ( "<STR_LIT>" , data ) <EOL> self . assertTrue ( allequal ( npcomp , data , "<STR_LIT>" ) ) <EOL> class AttributesOpenTestCase ( AttributesTestCase ) : <EOL> close = <NUM_LIT:0> <EOL> class AttributesCloseTestCase ( AttributesTestCase ) : <EOL> close = <NUM_LIT:1> <EOL> class StrlenTestCase ( common . TempFileMixin , TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( StrlenTestCase , self ) . setUp ( ) <EOL> group = self . h5file . create_group ( self . h5file . root , '<STR_LIT>' ) <EOL> tablelayout = { '<STR_LIT>' : StringCol ( itemsize = <NUM_LIT:1000> ) , } <EOL> self . table = self . h5file . create_table ( group , '<STR_LIT>' , tablelayout ) <EOL> self . table . flavor = '<STR_LIT>' <EOL> row = self . table . row <EOL> row [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> row . append ( ) <EOL> row [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> row . append ( ) <EOL> self . table . flush ( ) <EOL> def test01 ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> self . table = self . h5file . root . group . table <EOL> str1 = self . table . col ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> str2 = self . table . col ( '<STR_LIT>' ) [ <NUM_LIT:1> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , str1 ) <EOL> print ( "<STR_LIT>" , str2 ) <EOL> self . assertEqual ( len ( str1 ) , len ( b'<STR_LIT>' ) ) <EOL> self . assertEqual ( len ( str2 ) , len ( b'<STR_LIT>' ) ) <EOL> self . assertEqual ( str1 , b'<STR_LIT>' ) <EOL> self . assertEqual ( str2 , b'<STR_LIT>' ) <EOL> def test02 ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> self . table = self . h5file . root . group . table <EOL> str1 = self . table [ : ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> str2 = self . table [ : ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] <EOL> self . assertEqual ( len ( str1 ) , len ( b'<STR_LIT>' ) ) <EOL> self . assertEqual ( len ( str2 ) , len ( b'<STR_LIT>' ) ) <EOL> self . assertEqual ( str1 , b'<STR_LIT>' ) <EOL> self . assertEqual ( str2 , b'<STR_LIT>' ) <EOL> def test03 ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . close : <EOL> self . _reopen ( mode = '<STR_LIT:a>' ) <EOL> self . table = self . h5file . root . group . table <EOL> str1 = self . table [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> str2 = self . table [ <NUM_LIT:1> ] [ '<STR_LIT>' ] <EOL> self . assertEqual ( len ( str1 ) , len ( b'<STR_LIT>' ) ) <EOL> self . assertEqual ( len ( str2 ) , len ( b'<STR_LIT>' ) ) <EOL> self . assertEqual ( str1 , b'<STR_LIT>' ) <EOL> self . assertEqual ( str2 , b'<STR_LIT>' ) <EOL> class StrlenOpenTestCase ( StrlenTestCase ) : <EOL> close = <NUM_LIT:0> <EOL> class StrlenCloseTestCase ( StrlenTestCase ) : <EOL> close = <NUM_LIT:1> <EOL> def suite ( ) : <EOL> theSuite = unittest . TestSuite ( ) <EOL> niter = <NUM_LIT:1> <EOL> for i in range ( niter ) : <EOL> theSuite . addTest ( unittest . makeSuite ( Basic0DOneTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( Basic0DTwoTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( Basic1DOneTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( Basic1DTwoTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( Basic1DThreeTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( Basic2DTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( GroupsArrayTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( TableReadTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( TableNativeFlavorOpenTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( TableNativeFlavorCloseTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( AttributesOpenTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( AttributesCloseTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( StrlenOpenTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( StrlenCloseTestCase ) ) <EOL> if common . heavy : <EOL> theSuite . addTest ( unittest . makeSuite ( Basic10DTestCase ) ) <EOL> return theSuite <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> common . parse_argv ( sys . argv ) <EOL> common . print_versions ( ) <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
