<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> from __future__ import absolute_import <EOL> import sys <EOL> import itertools <EOL> import numpy <EOL> import tables as t <EOL> from tables . utils import SizeType <EOL> from tables . tests import common <EOL> from tables . tests . common import unittest , test_filename <EOL> from tables . tests . common import PyTablesTestCase as TestCase <EOL> from tables . description import Description <EOL> import six <EOL> from six . moves import range <EOL> minRowIndex = <NUM_LIT:10> <EOL> class Info ( t . IsDescription ) : <EOL> _v_pos = <NUM_LIT:3> <EOL> Name = t . StringCol ( itemsize = <NUM_LIT:2> ) <EOL> Value = t . ComplexCol ( itemsize = <NUM_LIT:16> ) <EOL> class TestTDescr ( t . IsDescription ) : <EOL> """<STR_LIT>""" <EOL> x = t . Int32Col ( dflt = <NUM_LIT:0> , shape = <NUM_LIT:2> , pos = <NUM_LIT:0> ) <EOL> y = t . Float64Col ( dflt = <NUM_LIT:1> , shape = ( <NUM_LIT:2> , <NUM_LIT:2> ) ) <EOL> z = t . UInt8Col ( dflt = <NUM_LIT:1> ) <EOL> color = t . StringCol ( itemsize = <NUM_LIT:2> , dflt = b"<STR_LIT:U+0020>" , pos = <NUM_LIT:2> ) <EOL> info = Info ( ) <EOL> class Info ( t . IsDescription ) : <EOL> _v_pos = <NUM_LIT:1> <EOL> name = t . StringCol ( itemsize = <NUM_LIT:2> ) <EOL> value = t . ComplexCol ( itemsize = <NUM_LIT:16> , pos = <NUM_LIT:0> ) <EOL> y2 = t . Float64Col ( dflt = <NUM_LIT:1> , pos = <NUM_LIT:1> ) <EOL> z2 = t . UInt8Col ( dflt = <NUM_LIT:1> ) <EOL> class Info2 ( t . IsDescription ) : <EOL> y3 = t . Time64Col ( dflt = <NUM_LIT:1> , shape = <NUM_LIT:2> ) <EOL> z3 = t . 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> name = t . StringCol ( itemsize = <NUM_LIT:2> ) <EOL> value = t . ComplexCol ( itemsize = <NUM_LIT:16> , shape = <NUM_LIT:2> ) <EOL> testADescr = [ <EOL> ( '<STR_LIT:x>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , [ <EOL> ( '<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>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:info>' , [ <EOL> ( '<STR_LIT:Name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ( '<STR_LIT:y>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:z>' , '<STR_LIT>' ) ] <EOL> testADescr2 = [ <EOL> ( '<STR_LIT:x>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , [ <EOL> ( '<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>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ( '<STR_LIT:name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:info>' , [ <EOL> ( '<STR_LIT:Name>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> ( '<STR_LIT:y>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT:z>' , '<STR_LIT>' ) ] <EOL> testABuffer = [ <EOL> ( ( <NUM_LIT:3> , <NUM_LIT:2> ) , ( <NUM_LIT> , <NUM_LIT> , ( '<STR_LIT>' , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:1> , <NUM_LIT:2> ) ) , <EOL> '<STR_LIT>' , <NUM_LIT:8> ) , '<STR_LIT>' , ( '<STR_LIT>' , <NUM_LIT> ) , ( ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) ) , <NUM_LIT:8> ) , <EOL> ( ( <NUM_LIT:4> , <NUM_LIT:3> ) , ( <NUM_LIT> , <NUM_LIT> , ( '<STR_LIT>' , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT:2> , <NUM_LIT:1> ) ) , <EOL> '<STR_LIT>' , <NUM_LIT:9> ) , '<STR_LIT>' , ( '<STR_LIT>' , <NUM_LIT> ) , ( ( <NUM_LIT> , <NUM_LIT> ) , ( <NUM_LIT> , <NUM_LIT> ) ) , <NUM_LIT:9> ) , <EOL> ] <EOL> testAData = numpy . array ( testABuffer , dtype = testADescr ) <EOL> testCondCol = '<STR_LIT>' <EOL> testNestedCol = '<STR_LIT>' <EOL> testCondition = '<STR_LIT>' <EOL> def areDescriptionsEqual ( desc1 , desc2 ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( desc1 , t . Col ) : <EOL> return ( desc1 . type == desc2 . type <EOL> and desc2 . dtype == desc2 . dtype <EOL> and desc1 . _v_pos == desc2 . _v_pos <EOL> and common . areArraysEqual ( desc1 . dflt , desc2 . dflt ) ) <EOL> if hasattr ( desc1 , '<STR_LIT>' ) : <EOL> cols1 = desc1 . _v_colobjects <EOL> elif hasattr ( desc1 , '<STR_LIT>' ) : <EOL> cols1 = desc1 . columns <EOL> else : <EOL> cols1 = desc1 <EOL> if hasattr ( desc2 , '<STR_LIT>' ) : <EOL> cols2 = desc2 . _v_colobjects <EOL> elif hasattr ( desc2 , '<STR_LIT>' ) : <EOL> cols2 = desc2 . columns <EOL> else : <EOL> cols2 = desc2 <EOL> if len ( cols1 ) != len ( cols2 ) : <EOL> return False <EOL> for ( colName , colobj1 ) in six . iteritems ( cols1 ) : <EOL> colobj2 = cols2 [ colName ] <EOL> if colName == '<STR_LIT>' : <EOL> return colobj1 == colobj2 <EOL> if not areDescriptionsEqual ( colobj1 , colobj2 ) : <EOL> return False <EOL> return True <EOL> class DescriptionTestCase ( TestCase ) : <EOL> _TestTDescr = TestTDescr <EOL> _testADescr = testADescr <EOL> _testADescr2 = testADescr2 <EOL> _testAData = testAData <EOL> def test00_instance ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertTrue ( <EOL> areDescriptionsEqual ( self . _TestTDescr , self . _TestTDescr ( ) ) , <EOL> "<STR_LIT>" ) <EOL> def test01_instance ( self ) : <EOL> """<STR_LIT>""" <EOL> descr = Description ( self . _TestTDescr ( ) . columns ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , descr . _v_nested_descr ) <EOL> print ( "<STR_LIT>" , self . _testADescr2 ) <EOL> self . assertEqual ( self . _testADescr2 , descr . _v_nested_descr , <EOL> "<STR_LIT>" ) <EOL> class CreateTestCase ( common . TempFileMixin , TestCase ) : <EOL> _TestTDescr = TestTDescr <EOL> _testABuffer = testABuffer <EOL> _testAData = testAData <EOL> def _checkColumns ( self , cols , desc ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( desc , t . Col ) : <EOL> return isinstance ( cols , t . Column ) <EOL> descColumns = desc . _v_colobjects <EOL> for colName in descColumns : <EOL> if colName not in cols . _v_colnames : <EOL> return False <EOL> if not self . _checkColumns ( cols . _f_col ( colName ) , <EOL> descColumns [ colName ] ) : <EOL> return False <EOL> return True <EOL> def _checkDescription ( self , table ) : <EOL> """<STR_LIT>""" <EOL> self . assertTrue ( <EOL> areDescriptionsEqual ( self . _TestTDescr , table . description ) , <EOL> "<STR_LIT>" ) <EOL> self . _checkColumns ( table . cols , table . description ) <EOL> def _checkColinstances ( self , table ) : <EOL> """<STR_LIT>""" <EOL> for colpathname in table . description . _v_pathnames : <EOL> self . assertTrue ( table . colinstances [ colpathname ] <EOL> is table . cols . _f_col ( colpathname ) ) <EOL> def test00_create ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> self . _checkDescription ( tbl ) <EOL> self . _checkColinstances ( tbl ) <EOL> def test01_open ( self ) : <EOL> """<STR_LIT>""" <EOL> self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> self . _checkDescription ( tbl ) <EOL> self . _checkColinstances ( tbl ) <EOL> def test02_NestedRecArrayCompat ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarr , self . _testAData ) , <EOL> "<STR_LIT>" ) <EOL> def test03_NRA ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _testAData , title = self . _getMethodName ( ) ) <EOL> tbl . flush ( ) <EOL> readAData = tbl . read ( ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , readAData ) <EOL> print ( "<STR_LIT>" , self . _testAData ) <EOL> self . assertTrue ( common . areArraysEqual ( self . _testAData , readAData ) , <EOL> "<STR_LIT>" ) <EOL> def test04_NRA2 ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> readAData = tbl . read ( ) <EOL> tbl2 = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT>' , readAData , title = self . _getMethodName ( ) ) <EOL> readAData2 = tbl2 . read ( ) <EOL> self . assertTrue ( common . areArraysEqual ( self . _testAData , readAData2 ) , <EOL> "<STR_LIT>" ) <EOL> class WriteTestCase ( common . TempFileMixin , TestCase ) : <EOL> _TestTDescr = TestTDescr <EOL> _testAData = testAData <EOL> _testCondition = testCondition <EOL> _testCondCol = testCondCol <EOL> _testNestedCol = testNestedCol <EOL> def _testCondVars ( self , table ) : <EOL> """<STR_LIT>""" <EOL> return { '<STR_LIT>' : table . cols . _f_col ( self . _testCondCol ) } <EOL> def _testNestedCondVars ( self , table ) : <EOL> """<STR_LIT>""" <EOL> return { '<STR_LIT>' : table . cols . _f_col ( self . _testNestedCol ) } <EOL> def _appendRow ( self , row , index ) : <EOL> """<STR_LIT>""" <EOL> record = self . _testAData [ index ] <EOL> for fieldName in self . _testAData . dtype . names : <EOL> row [ fieldName ] = record [ fieldName ] <EOL> row . append ( ) <EOL> def test00_append ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> tbl . flush ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> readAData = tbl . read ( ) <EOL> self . assertTrue ( common . areArraysEqual ( self . _testAData , readAData ) , <EOL> "<STR_LIT>" ) <EOL> def test01_row ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> row = tbl . row <EOL> self . _appendRow ( row , <NUM_LIT:0> ) <EOL> for i in range ( <NUM_LIT:1> , len ( self . _testAData ) ) : <EOL> self . _appendRow ( row , i ) <EOL> tbl . flush ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> readAData = tbl . read ( ) <EOL> self . assertTrue ( common . areArraysEqual ( self . _testAData , readAData ) , <EOL> "<STR_LIT>" ) <EOL> def test02_where ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> tbl . flush ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> searchedCoords = tbl . get_where_list ( <EOL> self . _testCondition , self . _testCondVars ( tbl ) ) <EOL> searchedCoords . sort ( ) <EOL> self . assertEqual ( searchedCoords . tolist ( ) , <EOL> list ( range ( len ( self . _testAData ) - <NUM_LIT:1> ) ) , <EOL> "<STR_LIT>" ) <EOL> def test02b_whereAppend ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl1 = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl1 . append ( self . _testAData ) <EOL> tbl1 . flush ( ) <EOL> tbl2 = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl1 . append_where ( <EOL> tbl2 , self . _testCondition , self . _testCondVars ( tbl1 ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl1 = self . h5file . root . test1 <EOL> tbl2 = self . h5file . root . test2 <EOL> searchedCoords = tbl2 . get_where_list ( <EOL> self . _testCondition , self . _testCondVars ( tbl2 ) ) <EOL> searchedCoords . sort ( ) <EOL> self . assertEqual ( searchedCoords . tolist ( ) , <EOL> list ( range ( len ( self . _testAData ) - <NUM_LIT:1> ) ) , <EOL> "<STR_LIT>" ) <EOL> def test03_colscond ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> tbl . flush ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> self . assertRaises ( <EOL> TypeError , tbl . get_where_list , <EOL> self . _testCondition , self . _testNestedCondVars ( tbl ) ) <EOL> def test04_modifyColumn ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> tbl . flush ( ) <EOL> nColumn = self . _testNestedCol <EOL> raTable = self . _testAData . copy ( ) <EOL> raColumn = raTable [ nColumn ] <EOL> ( raColumn [ <NUM_LIT:0> ] , raColumn [ - <NUM_LIT:1> ] ) = ( raColumn [ - <NUM_LIT:1> ] , raColumn [ <NUM_LIT:0> ] ) <EOL> tbl . modify_column ( colname = nColumn , column = raColumn ) <EOL> tbl . flush ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> raReadTable = tbl . read ( ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , raReadTable ) <EOL> print ( "<STR_LIT>" , raTable ) <EOL> self . assertTrue ( common . areArraysEqual ( raTable , raReadTable ) , <EOL> "<STR_LIT>" ) <EOL> def test05a_modifyColumns ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> tbl . flush ( ) <EOL> nColumn = self . _testNestedCol <EOL> raTable = self . _testAData . copy ( ) <EOL> raColumn = raTable [ nColumn ] <EOL> ( raColumn [ <NUM_LIT:0> ] , raColumn [ - <NUM_LIT:1> ] ) = ( raColumn [ - <NUM_LIT:1> ] . copy ( ) , raColumn [ <NUM_LIT:0> ] . copy ( ) ) <EOL> newdtype = numpy . dtype ( [ ( nColumn , raTable . dtype . fields [ nColumn ] [ <NUM_LIT:0> ] ) ] ) <EOL> self . assertTrue ( newdtype is not None ) <EOL> tbl . modify_columns ( names = [ nColumn ] , columns = raColumn ) <EOL> tbl . flush ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> raReadTable = tbl . read ( ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , raReadTable ) <EOL> print ( "<STR_LIT>" , raTable ) <EOL> self . assertTrue ( common . areArraysEqual ( raTable , raReadTable ) , <EOL> "<STR_LIT>" ) <EOL> def test05b_modifyColumns ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> tbl . flush ( ) <EOL> colnames = [ '<STR_LIT:x>' , '<STR_LIT>' ] <EOL> raCols = numpy . rec . fromarrays ( [ <EOL> self . _testAData [ '<STR_LIT:x>' ] . copy ( ) , <EOL> self . _testAData [ '<STR_LIT>' ] . copy ( ) ] , <EOL> dtype = [ ( '<STR_LIT:x>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> ( raCols [ <NUM_LIT:0> ] , raCols [ - <NUM_LIT:1> ] ) = ( raCols [ - <NUM_LIT:1> ] . copy ( ) , raCols [ <NUM_LIT:0> ] . copy ( ) ) <EOL> tbl . modify_columns ( names = colnames , columns = raCols ) <EOL> tbl . flush ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> raCols2 = numpy . rec . fromarrays ( [ tbl . cols . _f_col ( '<STR_LIT:x>' ) , <EOL> tbl . cols . _f_col ( '<STR_LIT>' ) ] , <EOL> dtype = raCols . dtype ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , raCols2 ) <EOL> print ( "<STR_LIT>" , raCols ) <EOL> self . assertTrue ( common . areArraysEqual ( raCols , raCols2 ) , <EOL> "<STR_LIT>" ) <EOL> def test06_modifyRows ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> tbl . flush ( ) <EOL> raTable = self . _testAData . copy ( ) <EOL> ( raTable [ <NUM_LIT:0> ] , raTable [ - <NUM_LIT:1> ] ) = ( raTable [ - <NUM_LIT:1> ] . copy ( ) , raTable [ <NUM_LIT:0> ] . copy ( ) ) <EOL> tbl . modify_rows ( start = <NUM_LIT:0> , stop = <NUM_LIT:2> , rows = raTable ) <EOL> tbl . flush ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> raReadTable = tbl . read ( ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , raReadTable ) <EOL> print ( "<STR_LIT>" , raTable ) <EOL> self . assertTrue ( common . areArraysEqual ( raTable , raReadTable ) , <EOL> "<STR_LIT>" ) <EOL> def test07_index ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) , <EOL> expectedrows = minRowIndex * <NUM_LIT:2> ) <EOL> for i in range ( minRowIndex ) : <EOL> tbl . append ( self . _testAData ) <EOL> tbl . flush ( ) <EOL> coltoindex = tbl . cols . _f_col ( self . _testCondCol ) <EOL> indexrows = coltoindex . create_index ( ) <EOL> self . assertTrue ( indexrows is not None ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> coltoindex = tbl . cols . _f_col ( self . _testCondCol ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tbl . nrows ) <EOL> print ( "<STR_LIT>" , coltoindex . index . nelements ) <EOL> self . assertEqual ( tbl . indexed , True , "<STR_LIT>" ) <EOL> self . assertNotEqual ( coltoindex . index , None , "<STR_LIT>" ) <EOL> self . assertTrue ( tbl . colindexed [ <EOL> self . _testCondCol ] , "<STR_LIT>" ) <EOL> searchedCoords = tbl . get_where_list ( <EOL> self . _testCondition , self . _testCondVars ( tbl ) ) <EOL> searchedCoords . sort ( ) <EOL> expectedCoords = numpy . arange ( <NUM_LIT:0> , minRowIndex * <NUM_LIT:2> , <NUM_LIT:2> , SizeType ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , searchedCoords ) <EOL> print ( "<STR_LIT>" , expectedCoords ) <EOL> self . assertEqual ( searchedCoords . tolist ( ) , expectedCoords . tolist ( ) , <EOL> "<STR_LIT>" ) <EOL> def test08_setNestedField ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> tbl . flush ( ) <EOL> oldvalue = tbl . cols . Info . z2 [ <NUM_LIT:0> ] <EOL> tbl . cols . Info . z2 [ <NUM_LIT:0> ] = oldvalue + <NUM_LIT:1> <EOL> tbl . flush ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> newvalue = tbl . cols . Info . z2 [ <NUM_LIT:0> ] <EOL> self . assertEqual ( newvalue , oldvalue + <NUM_LIT:1> ) <EOL> class WriteNoReopen ( WriteTestCase ) : <EOL> reopen = <NUM_LIT:0> <EOL> class WriteReopen ( WriteTestCase ) : <EOL> reopen = <NUM_LIT:1> <EOL> class ReadTestCase ( common . TempFileMixin , TestCase ) : <EOL> _TestTDescr = TestTDescr <EOL> _testABuffer = testABuffer <EOL> _testAData = testAData <EOL> _testNestedCol = testNestedCol <EOL> def test00a_repr ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = "<STR_LIT>" ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , str ( tbl ) ) <EOL> print ( "<STR_LIT>" , repr ( tbl ) ) <EOL> self . assertEqual ( str ( tbl ) , "<STR_LIT>" ) <EOL> tblrepr = repr ( tbl ) <EOL> tblrepr = "<STR_LIT:\n>" . join ( tblrepr . split ( "<STR_LIT:\n>" ) [ : - <NUM_LIT:2> ] ) + "<STR_LIT:\n>" <EOL> if sys . version_info [ <NUM_LIT:0> ] < <NUM_LIT:3> : <EOL> template = """<STR_LIT>""" <EOL> else : <EOL> template = """<STR_LIT>""" <EOL> enums = [ <EOL> '<STR_LIT:U+002CU+0020>' . join ( items ) for items in itertools . permutations ( <EOL> ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> ] <EOL> defaults = ( '<STR_LIT:r>' , '<STR_LIT:b>' , '<STR_LIT:g>' ) <EOL> values = [ <EOL> template % { '<STR_LIT:value>' : v , '<STR_LIT:default>' : d } <EOL> for v , d in itertools . product ( enums , defaults ) <EOL> ] <EOL> self . assertTrue ( tblrepr in values ) <EOL> def test00b_repr ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = "<STR_LIT>" ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" % str ( tbl . cols . y ) ) <EOL> print ( "<STR_LIT>" % repr ( tbl . cols . y ) ) <EOL> self . assertEqual ( str ( tbl . cols . y ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( repr ( tbl . cols . y ) , <EOL> "<STR_LIT>" ) <EOL> def test00c_repr ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = "<STR_LIT>" ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" % str ( tbl . cols . Info . z2 ) ) <EOL> print ( "<STR_LIT>" % repr ( tbl . cols . Info . z2 ) ) <EOL> self . assertEqual ( str ( tbl . cols . Info . z2 ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( repr ( tbl . cols . Info . z2 ) , <EOL> "<STR_LIT>" ) <EOL> def test01_read ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . rec . array ( testABuffer , <EOL> dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . read ( start = <NUM_LIT:0> , step = <NUM_LIT:2> , field = '<STR_LIT>' ) <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test01_read_out_arg ( self ) : <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . rec . array ( testABuffer , <EOL> dtype = tbl . description . _v_nested_descr ) <EOL> all_cols = numpy . empty ( <NUM_LIT:1> , tbl . dtype ) <EOL> tblcols = tbl . read ( start = <NUM_LIT:0> , step = <NUM_LIT:2> , field = '<STR_LIT>' , out = all_cols ) <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarr [ <NUM_LIT:0> : : <NUM_LIT:2> ] , all_cols ) , <EOL> "<STR_LIT>" ) <EOL> def test02_read ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> tblcols = tbl . read ( start = <NUM_LIT:0> , step = <NUM_LIT:2> , field = '<STR_LIT>' ) <EOL> nrarr = numpy . rec . array ( testABuffer , <EOL> dtype = tbl . description . _v_nested_descr ) <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ '<STR_LIT:value>' ] [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test02_read_out_arg ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> tblcols = numpy . empty ( <NUM_LIT:1> , dtype = '<STR_LIT>' ) <EOL> tbl . read ( start = <NUM_LIT:0> , step = <NUM_LIT:2> , field = '<STR_LIT>' , out = tblcols ) <EOL> nrarr = numpy . rec . array ( testABuffer , <EOL> dtype = tbl . description . _v_nested_descr ) <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ '<STR_LIT:value>' ] [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> class ReadNoReopen ( ReadTestCase ) : <EOL> reopen = <NUM_LIT:0> <EOL> class ReadReopen ( ReadTestCase ) : <EOL> reopen = <NUM_LIT:1> <EOL> class ColsTestCase ( common . TempFileMixin , TestCase ) : <EOL> _TestTDescr = TestTDescr <EOL> _testABuffer = testABuffer <EOL> _testAData = testAData <EOL> _testNestedCol = testNestedCol <EOL> def test00a_repr ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = "<STR_LIT>" ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , str ( tbl . cols ) ) <EOL> print ( "<STR_LIT>" , repr ( tbl . cols ) ) <EOL> self . assertEqual ( str ( tbl . cols ) , "<STR_LIT>" ) <EOL> try : <EOL> self . assertEqual ( repr ( tbl . cols ) , <EOL> """<STR_LIT>""" <EOL> ) <EOL> except AssertionError : <EOL> self . assertEqual ( repr ( tbl . cols ) , <EOL> """<STR_LIT>""" % ( numpy . int32 ( <NUM_LIT:0> ) . dtype . str , numpy . float64 ( <NUM_LIT:0> ) . dtype . str ) ) <EOL> def test00b_repr ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , str ( tbl . cols . Info ) ) <EOL> print ( "<STR_LIT>" , repr ( tbl . cols . Info ) ) <EOL> self . assertEqual ( str ( <EOL> tbl . cols . Info ) , "<STR_LIT>" ) <EOL> self . assertEqual ( repr ( tbl . cols . Info ) , <EOL> """<STR_LIT>""" ) <EOL> def test01a_f_col ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> tblcol = tbl . cols . _f_col ( self . _testNestedCol ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcol . _v_desc . _v_pathname ) <EOL> self . assertEqual ( tblcol . _v_desc . _v_pathname , self . _testNestedCol , <EOL> "<STR_LIT>" ) <EOL> def test01b_f_col ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> tblcol = tbl . cols . _f_col ( self . _testNestedCol + "<STR_LIT>" ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcol . name ) <EOL> self . assertEqual ( tblcol . name , "<STR_LIT:name>" , "<STR_LIT>" ) <EOL> def test01c_f_col ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tblcol = tbl . cols . _f_col ( self . _testNestedCol + "<STR_LIT>" ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcol . _v_desc . _v_pathname ) <EOL> self . assertEqual ( tblcol . _v_desc . _v_pathname , <EOL> self . _testNestedCol + "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> def test02a__len__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> length = len ( tbl . cols ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , length ) <EOL> self . assertEqual ( length , len ( tbl . colnames ) , <EOL> "<STR_LIT>" ) <EOL> def test02b__len__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> length = len ( tbl . cols . Info ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , length ) <EOL> self . assertEqual ( length , len ( tbl . cols . Info . _v_colnames ) , <EOL> "<STR_LIT>" ) <EOL> def test03a__getitem__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . cols [ <NUM_LIT:1> ] <EOL> nrarrcols = nrarr [ <NUM_LIT:1> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test03b__getitem__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . cols [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> nrarrcols = nrarr [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test03c__getitem__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . cols [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> nrarrcols = nrarr [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test04a__getitem__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . cols . _f_col ( '<STR_LIT>' ) [ <NUM_LIT:1> ] <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ <NUM_LIT:1> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test04b__getitem__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . cols . _f_col ( '<STR_LIT>' ) [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test04c__getitem__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . cols . _f_col ( '<STR_LIT>' ) [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test05a__getitem__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . cols . _f_col ( '<STR_LIT>' ) [ <NUM_LIT:1> ] <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ '<STR_LIT:value>' ] [ <NUM_LIT:1> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertEqual ( nrarrcols , tblcols , <EOL> "<STR_LIT>" ) <EOL> def test05b__getitem__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . cols . _f_col ( '<STR_LIT>' ) [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ '<STR_LIT:value>' ] [ <NUM_LIT:0> : <NUM_LIT:2> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test05c__getitem__ ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> tblcols = tbl . cols . _f_col ( '<STR_LIT>' ) [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> nrarrcols = nrarr [ '<STR_LIT>' ] [ '<STR_LIT:value>' ] [ <NUM_LIT:0> : : <NUM_LIT:2> ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tblcols ) <EOL> print ( "<STR_LIT>" , nrarrcols ) <EOL> self . assertTrue ( common . areArraysEqual ( nrarrcols , tblcols ) , <EOL> "<STR_LIT>" ) <EOL> def test_01a__iter__ ( self ) : <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , self . _TestTDescr , title = self . _getMethodName ( ) ) <EOL> tbl . append ( self . _testAData ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> nrarr = numpy . array ( testABuffer , dtype = tbl . description . _v_nested_descr ) <EOL> row_num = <NUM_LIT:0> <EOL> for item in tbl . cols . Info . value : <EOL> self . assertEqual ( item , nrarr [ '<STR_LIT>' ] [ '<STR_LIT:value>' ] [ row_num ] ) <EOL> row_num += <NUM_LIT:1> <EOL> self . assertEqual ( row_num , len ( nrarr ) ) <EOL> class ColsNoReopen ( ColsTestCase ) : <EOL> reopen = <NUM_LIT:0> <EOL> class ColsReopen ( ColsTestCase ) : <EOL> reopen = <NUM_LIT:1> <EOL> class Nested ( t . IsDescription ) : <EOL> uid = t . IntCol ( pos = <NUM_LIT:1> ) <EOL> value = t . FloatCol ( pos = <NUM_LIT:2> ) <EOL> class A_Candidate ( t . IsDescription ) : <EOL> nested1 = Nested ( ) <EOL> nested2 = Nested ( ) <EOL> class B_Candidate ( t . IsDescription ) : <EOL> nested1 = Nested <EOL> nested2 = Nested <EOL> class C_Candidate ( t . IsDescription ) : <EOL> nested1 = Nested ( ) <EOL> nested2 = Nested <EOL> Dnested = { <EOL> '<STR_LIT>' : t . IntCol ( pos = <NUM_LIT:1> ) , <EOL> '<STR_LIT:value>' : t . FloatCol ( pos = <NUM_LIT:2> ) , <EOL> } <EOL> D_Candidate = { <EOL> "<STR_LIT>" : Dnested , <EOL> "<STR_LIT>" : Dnested , <EOL> } <EOL> E_Candidate = { <EOL> "<STR_LIT>" : Nested , <EOL> "<STR_LIT>" : Dnested , <EOL> } <EOL> F_Candidate = { <EOL> "<STR_LIT>" : Nested ( ) , <EOL> "<STR_LIT>" : Dnested , <EOL> } <EOL> class SameNestedTestCase ( common . TempFileMixin , TestCase ) : <EOL> correct_names = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ] <EOL> def test01a ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , A_Candidate , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> names = [ col . _v_pathname for col in tbl . description . _f_walk ( <EOL> type = "<STR_LIT>" ) ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , names ) <EOL> print ( "<STR_LIT>" , self . correct_names ) <EOL> self . assertEqual ( names , self . correct_names , <EOL> "<STR_LIT>" ) <EOL> def test01b ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , B_Candidate , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> names = [ col . _v_pathname for col in tbl . description . _f_walk ( <EOL> type = "<STR_LIT>" ) ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , names ) <EOL> print ( "<STR_LIT>" , self . correct_names ) <EOL> self . assertEqual ( names , self . correct_names , <EOL> "<STR_LIT>" ) <EOL> def test01c ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , C_Candidate , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> names = [ col . _v_pathname for col in tbl . description . _f_walk ( <EOL> type = "<STR_LIT>" ) ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , names ) <EOL> print ( "<STR_LIT>" , self . correct_names ) <EOL> self . assertEqual ( names , self . correct_names , <EOL> "<STR_LIT>" ) <EOL> def test01d ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , D_Candidate , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> names = [ col . _v_pathname for col in tbl . description . _f_walk ( <EOL> type = "<STR_LIT>" ) ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , names ) <EOL> print ( "<STR_LIT>" , self . correct_names ) <EOL> self . assertEqual ( names , self . correct_names , <EOL> "<STR_LIT>" ) <EOL> def test01e ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , E_Candidate , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> names = [ col . _v_pathname for col in tbl . description . _f_walk ( <EOL> type = "<STR_LIT>" ) ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , names ) <EOL> print ( "<STR_LIT>" , self . correct_names ) <EOL> self . assertEqual ( names , self . correct_names , <EOL> "<STR_LIT>" ) <EOL> def test01f ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , F_Candidate , title = self . _getMethodName ( ) ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> names = [ col . _v_pathname for col in tbl . description . _f_walk ( <EOL> type = "<STR_LIT>" ) ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , names ) <EOL> print ( "<STR_LIT>" , self . correct_names ) <EOL> self . assertEqual ( names , self . correct_names , <EOL> "<STR_LIT>" ) <EOL> def test02a ( self ) : <EOL> """<STR_LIT>""" <EOL> desc = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : t . Int32Col ( ) , <EOL> '<STR_LIT>' : t . Int32Col ( ) <EOL> } <EOL> } <EOL> i1 = '<STR_LIT>' <EOL> i2 = '<STR_LIT>' <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , desc , title = self . _getMethodName ( ) ) <EOL> row = tbl . row <EOL> for i in range ( <NUM_LIT:1000> ) : <EOL> row [ i1 ] = i <EOL> row [ i2 ] = i * <NUM_LIT:2> <EOL> row . append ( ) <EOL> tbl . flush ( ) <EOL> cols = { <EOL> '<STR_LIT>' : tbl . cols . nested . i1 , <EOL> '<STR_LIT>' : tbl . cols . nested . i2 , <EOL> } <EOL> cols [ '<STR_LIT>' ] . create_index ( ) <EOL> cols [ '<STR_LIT>' ] . create_index ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> cols = { '<STR_LIT>' : tbl . cols . nested . i1 , <EOL> '<STR_LIT>' : tbl . cols . nested . i2 , } <EOL> i1res = [ r [ i1 ] for r in tbl . where ( '<STR_LIT>' , cols ) ] <EOL> i2res = [ r [ i2 ] for r in tbl . where ( '<STR_LIT>' , cols ) ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , i1res ) <EOL> print ( "<STR_LIT>" , list ( range ( <NUM_LIT:10> ) ) ) <EOL> print ( "<STR_LIT>" , i2res ) <EOL> print ( "<STR_LIT>" , list ( range ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:2> ) ) ) <EOL> self . assertEqual ( i1res , list ( range ( <NUM_LIT:10> ) ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( i2res , list ( range ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:2> ) ) , <EOL> "<STR_LIT>" ) <EOL> def test02b ( self ) : <EOL> """<STR_LIT>""" <EOL> desc = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : t . Int32Col ( ) , <EOL> '<STR_LIT>' : t . Int32Col ( ) <EOL> } <EOL> } <EOL> } <EOL> } <EOL> i1 = '<STR_LIT>' <EOL> i2 = '<STR_LIT>' <EOL> tbl = self . h5file . create_table ( <EOL> '<STR_LIT:/>' , '<STR_LIT:test>' , desc , title = self . _getMethodName ( ) ) <EOL> row = tbl . row <EOL> for i in range ( <NUM_LIT:1000> ) : <EOL> row [ i1 ] = i <EOL> row [ i2 ] = i * <NUM_LIT:2> <EOL> row . append ( ) <EOL> tbl . flush ( ) <EOL> cols = { '<STR_LIT>' : tbl . cols . nested1 . nested2 . nested3 . i1 , <EOL> '<STR_LIT>' : tbl . cols . nested1 . nested2 . nested3 . i2 , } <EOL> cols [ '<STR_LIT>' ] . create_index ( ) <EOL> cols [ '<STR_LIT>' ] . create_index ( ) <EOL> if self . reopen : <EOL> self . _reopen ( ) <EOL> tbl = self . h5file . root . test <EOL> cols = { '<STR_LIT>' : tbl . cols . nested1 . nested2 . nested3 . i1 , <EOL> '<STR_LIT>' : tbl . cols . nested1 . nested2 . nested3 . i2 , } <EOL> i1res = [ r [ i1 ] for r in tbl . where ( '<STR_LIT>' , cols ) ] <EOL> i2res = [ r [ i2 ] for r in tbl . where ( '<STR_LIT>' , cols ) ] <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , i1res ) <EOL> print ( "<STR_LIT>" , list ( range ( <NUM_LIT:10> ) ) ) <EOL> print ( "<STR_LIT>" , i2res ) <EOL> print ( "<STR_LIT>" , list ( range ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:2> ) ) ) <EOL> self . assertEqual ( i1res , list ( range ( <NUM_LIT:10> ) ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( i2res , list ( range ( <NUM_LIT:0> , <NUM_LIT:10> , <NUM_LIT:2> ) ) , <EOL> "<STR_LIT>" ) <EOL> class SameNestedNoReopen ( SameNestedTestCase ) : <EOL> reopen = <NUM_LIT:0> <EOL> class SameNestedReopen ( SameNestedTestCase ) : <EOL> reopen = <NUM_LIT:1> <EOL> class NestedTypesWithGaps ( common . TestFileMixin , TestCase ) : <EOL> h5fname = test_filename ( '<STR_LIT>' ) <EOL> correct_descr = """<STR_LIT>""" <EOL> def test01 ( self ) : <EOL> """<STR_LIT>""" <EOL> tbl = self . h5file . get_node ( '<STR_LIT>' ) <EOL> type_descr = repr ( tbl . description ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" , tbl . description . _v_itemsize ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" , type_descr ) <EOL> print ( "<STR_LIT>" , self . correct_descr ) <EOL> self . assertEqual ( tbl . description . _v_itemsize , <NUM_LIT> ) <EOL> self . assertEqual ( type_descr , self . correct_descr ) <EOL> if common . verbose : <EOL> print ( "<STR_LIT>" ) <EOL> def suite ( ) : <EOL> """<STR_LIT>""" <EOL> theSuite = unittest . TestSuite ( ) <EOL> niter = <NUM_LIT:1> <EOL> for i in range ( niter ) : <EOL> theSuite . addTest ( unittest . makeSuite ( DescriptionTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( CreateTestCase ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( WriteNoReopen ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( WriteReopen ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( ColsNoReopen ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( ColsReopen ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( ReadNoReopen ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( ReadReopen ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( SameNestedNoReopen ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( SameNestedReopen ) ) <EOL> theSuite . addTest ( unittest . makeSuite ( NestedTypesWithGaps ) ) <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>
