@pytest.mark.parametrize('parallel', [True, False])
def test_commented_header(parallel, read_commented_header):
 text = '\n # A B C\n 1 2 3\n 4 5 6\n'
 t1 = read_commented_header(text, parallel=parallel)
 expected = Table([[1, 4], [2, 5], [3, 6]], names=('A', 'B', 'C'))
 assert_table_equal(t1, expected)
 text = ('# first commented line\n # second commented line\n\n' + text)
 t2 = read_commented_header(text, header_start=2, data_start=0, parallel=parallel)
 assert_table_equal(t2, expected)
 t3 = read_commented_header(text, header_start=(-1), data_start=0, parallel=parallel)
 assert_table_equal(t3, expected)
 text += '7 8 9'
 t4 = read_commented_header(text, header_start=2, data_start=2, parallel=parallel)
 expected = Table([[7], [8], [9]], names=('A', 'B', 'C'))
 assert_table_equal(t4, expected)
 with pytest.raises(ParameterError):
  read_commented_header(text, header_start=(-1), data_start=(-1), parallel=parallel)

@ pytest . mark . parametrize ( 'parallel' , [ True , False ] ) def test_commented_header ( parallel , read_commented_header ) : text = '\n # A B C\n 1 2 3\n 4 5 6\n' t1 = read_commented_header ( text , parallel = parallel ) expected = Table ( [ [ 1 , 4 ] , [ 2 , 5 ] , [ 3 , 6 ] ] , names = ( 'A' , 'B' , 'C' ) ) assert_table_equal ( t1 , expected ) text = ( '# first commented line\n # second commented line\n\n' + text ) t2 = read_commented_header ( text , header_start = 2 , data_start = 0 , parallel = parallel ) assert_table_equal ( t2 , expected ) t3 = read_commented_header ( text , header_start = ( - 1 ) , data_start = 0 , parallel = parallel ) assert_table_equal ( t3 , expected ) text += '7 8 9' t4 = read_commented_header ( text , header_start = 2 , data_start = 2 , parallel = parallel ) expected = Table ( [ [ 7 ] , [ 8 ] , [ 9 ] ] , names = ( 'A' , 'B' , 'C' ) ) assert_table_equal ( t4 , expected ) with pytest . raises ( ParameterError ) : read_commented_header ( text , header_start = ( - 1 ) , data_start = ( - 1 ) , parallel = parallel )
the fastcommentedheader reader should mimic the behavior of the commentedheader by overriding the default header behavior of fastbasic .