<s> import pyexcel as pe <EOL> from _compact import OrderedDict <EOL> from nose . tools import raises <EOL> class TestFormattableSheet : <EOL> def setUp ( self ) : <EOL> self . data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ] , <EOL> [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" , "<STR_LIT:4>" , "<STR_LIT:5>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] , <EOL> [ "<STR_LIT:2>" , "<STR_LIT:3>" , "<STR_LIT:4>" , "<STR_LIT:5>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> ] <EOL> def test_apply_row_formatter ( self ) : <EOL> s = pe . sheets . FormattableSheet ( self . data ) <EOL> s . apply_formatter ( pe . formatters . RowFormatter ( <NUM_LIT:0> , str ) ) <EOL> assert s . row [ <NUM_LIT:0> ] == s . row [ <NUM_LIT:1> ] <EOL> def test_apply_column_formatter ( self ) : <EOL> s = pe . sheets . FormattableSheet ( self . data ) <EOL> s . apply_formatter ( pe . formatters . ColumnFormatter ( <NUM_LIT:0> , float ) ) <EOL> assert s . column [ <NUM_LIT:0> ] == [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:2> ] <EOL> def test_apply_sheet_formatter ( self ) : <EOL> s = pe . sheets . FormattableSheet ( self . data ) <EOL> s . apply_formatter ( pe . formatters . SheetFormatter ( float ) ) <EOL> assert s . row [ <NUM_LIT:0> ] == s . row [ <NUM_LIT:1> ] <EOL> assert s . column [ <NUM_LIT:0> ] == [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:2> ] <EOL> def test_freeze_formatter ( self ) : <EOL> s = pe . sheets . FormattableSheet ( self . data ) <EOL> s . freeze_formatters ( ) <EOL> def test_empty_sheet ( self ) : <EOL> s = pe . sheets . FormattableSheet ( [ ] ) <EOL> ret = s . cell_value ( <NUM_LIT:100> , <NUM_LIT:100> ) <EOL> assert ret is None <EOL> ret = s . _cell_value ( <NUM_LIT:100> , <NUM_LIT:100> ) <EOL> assert ret == "<STR_LIT>" <EOL> class TestFilterSheet : <EOL> def test_freeze_filters ( self ) : <EOL> data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> ] <EOL> s = pe . sheets . FilterableSheet ( data ) <EOL> s . add_filter ( pe . filters . EvenRowFilter ( ) ) <EOL> s . freeze_filters ( ) <EOL> assert s . row [ <NUM_LIT:0> ] == [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> assert s . column [ <NUM_LIT:0> ] == [ <NUM_LIT:1> ] <EOL> @ raises ( NotImplementedError ) <EOL> def test_non_filter ( self ) : <EOL> data = [ ] <EOL> s = pe . sheets . FilterableSheet ( data ) <EOL> s . filter ( "<STR_LIT:abc>" ) <EOL> class TestSheetNamedColumn : <EOL> def setUp ( self ) : <EOL> self . data = [ <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> [ <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] <EOL> ] <EOL> def test_formatter_by_named_column ( self ) : <EOL> """<STR_LIT>""" <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:0> ) <EOL> f = pe . formatters . NamedColumnFormatter ( "<STR_LIT>" , str ) <EOL> s . apply_formatter ( f ) <EOL> assert s . column [ "<STR_LIT>" ] == [ "<STR_LIT:1>" , "<STR_LIT:4>" , "<STR_LIT>" ] <EOL> def test_formatter_by_named_columns ( self ) : <EOL> """<STR_LIT>""" <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:0> ) <EOL> f = pe . formatters . NamedColumnFormatter ( [ "<STR_LIT>" , "<STR_LIT>" ] , str ) <EOL> s . apply_formatter ( f ) <EOL> assert s . column [ "<STR_LIT>" ] == [ "<STR_LIT:1>" , "<STR_LIT:4>" , "<STR_LIT>" ] <EOL> assert s . column [ "<STR_LIT>" ] == [ "<STR_LIT:3>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> @ raises ( IndexError ) <EOL> def test_formatter_by_named_column3 ( self ) : <EOL> """<STR_LIT>""" <EOL> pe . formatters . NamedColumnFormatter ( [ "<STR_LIT>" , <NUM_LIT:1> ] , str ) <EOL> @ raises ( IndexError ) <EOL> def test_empty_list_in_named_column_formatter ( self ) : <EOL> pe . formatters . NamedColumnFormatter ( [ ] , str ) <EOL> @ raises ( NotImplementedError ) <EOL> def test_float_in_list_for_named_column_formatter ( self ) : <EOL> pe . formatters . NamedColumnFormatter ( <NUM_LIT> , str ) <EOL> def test_add ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:0> ) <EOL> data = OrderedDict ( { <EOL> "<STR_LIT>" : [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> ] <EOL> } ) <EOL> s = s . column + data <EOL> assert s . column [ "<STR_LIT>" ] == [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> ] <EOL> @ raises ( TypeError ) <EOL> def test_add_wrong_type ( self ) : <EOL> """<STR_LIT>""" <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:0> ) <EOL> s = s . column + "<STR_LIT>" <EOL> @ raises ( ValueError ) <EOL> def test_delete_named_column ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:0> ) <EOL> del s . column [ "<STR_LIT>" ] <EOL> assert s . number_of_columns ( ) == <NUM_LIT:2> <EOL> s . column [ "<STR_LIT>" ] <EOL> @ raises ( ValueError ) <EOL> def test_delete_indexed_column1 ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:0> ) <EOL> del s . column [ <NUM_LIT:1> ] <EOL> assert s . number_of_columns ( ) == <NUM_LIT:2> <EOL> s . column [ "<STR_LIT>" ] <EOL> @ raises ( ValueError ) <EOL> def test_delete_indexed_column2 ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:0> ) <EOL> del s . column [ "<STR_LIT>" ] <EOL> assert s . number_of_columns ( ) == <NUM_LIT:2> <EOL> s . column [ "<STR_LIT>" ] <EOL> @ raises ( ValueError ) <EOL> def test_delete_indexed_column ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:0> ) <EOL> s . delete_named_column_at ( <NUM_LIT:1> ) <EOL> assert s . number_of_columns ( ) == <NUM_LIT:2> <EOL> s . column [ "<STR_LIT>" ] <EOL> class TestSheetNamedColumn2 : <EOL> def setUp ( self ) : <EOL> self . data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] <EOL> ] <EOL> def test_series ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:2> ) <EOL> assert s . colnames == [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> custom_columns = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> s . colnames = custom_columns <EOL> assert s . colnames == custom_columns <EOL> def test_series2 ( self ) : <EOL> custom_columns = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" , colnames = custom_columns ) <EOL> assert s . colnames == custom_columns <EOL> @ raises ( NotImplementedError ) <EOL> def test_series3 ( self ) : <EOL> custom_columns = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" , colnames = custom_columns , <EOL> name_columns_by_row = <NUM_LIT:0> ) <EOL> def test_formatter_by_named_column ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:2> ) <EOL> f = pe . formatters . NamedColumnFormatter ( "<STR_LIT>" , str ) <EOL> s . apply_formatter ( f ) <EOL> assert s . column [ "<STR_LIT>" ] == [ "<STR_LIT:1>" , "<STR_LIT:4>" , "<STR_LIT>" ] <EOL> def test_formatter_by_named_column_2 ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:2> ) <EOL> s . column . format ( "<STR_LIT>" , str ) <EOL> assert s . column [ "<STR_LIT>" ] == [ "<STR_LIT:1>" , "<STR_LIT:4>" , "<STR_LIT>" ] <EOL> def test_add ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:2> ) <EOL> data = OrderedDict ( { <EOL> "<STR_LIT>" : [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> ] <EOL> } <EOL> ) <EOL> s = s . column + data <EOL> assert s . column [ "<STR_LIT>" ] == [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> ] <EOL> @ raises ( ValueError ) <EOL> def test_delete_named_column ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:2> ) <EOL> del s . column [ "<STR_LIT>" ] <EOL> assert s . number_of_columns ( ) == <NUM_LIT:2> <EOL> s . column [ "<STR_LIT>" ] <EOL> def test_set_indexed_row ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_columns_by_row ( <NUM_LIT:2> ) <EOL> s . row [ <NUM_LIT:0> ] = [ <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:11> ] <EOL> assert s . row [ <NUM_LIT:0> ] == [ <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:11> ] <EOL> class TestSheetNamedRow : <EOL> def setUp ( self ) : <EOL> self . data = [ <EOL> [ "<STR_LIT>" , - <NUM_LIT:1> , - <NUM_LIT:2> , - <NUM_LIT:3> ] , <EOL> [ "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <EOL> [ "<STR_LIT>" , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> [ "<STR_LIT>" , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] <EOL> ] <EOL> def test_formatter_by_named_row ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> f = pe . formatters . NamedRowFormatter ( "<STR_LIT>" , str ) <EOL> s . apply_formatter ( f ) <EOL> assert s . row [ "<STR_LIT>" ] == [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" ] <EOL> def test_rownames ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" , name_rows_by_column = <NUM_LIT:0> ) <EOL> assert s . rownames == [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> custom_rows = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> s . rownames = custom_rows <EOL> assert s . rownames == custom_rows <EOL> def test_rownames2 ( self ) : <EOL> custom_rows = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" , rownames = custom_rows ) <EOL> assert s . rownames == custom_rows <EOL> @ raises ( NotImplementedError ) <EOL> def test_rownames3 ( self ) : <EOL> custom_rows = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" , name_rows_by_column = <NUM_LIT:0> , <EOL> rownames = custom_rows ) <EOL> def test_formatter_by_named_row_2 ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> s . row . format ( "<STR_LIT>" , str ) <EOL> assert s . row [ "<STR_LIT>" ] == [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" ] <EOL> def test_row_series_to_dict ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> content = s . to_dict ( True ) <EOL> keys = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> assert keys == list ( content . keys ( ) ) <EOL> @ raises ( TypeError ) <EOL> def test_extend_rows_using_wrong_data_type ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> s . extend_rows ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> def test_formatter_by_named_row2 ( self ) : <EOL> """<STR_LIT>""" <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> f = pe . formatters . NamedRowFormatter ( [ "<STR_LIT>" , "<STR_LIT>" ] , str ) <EOL> s . apply_formatter ( f ) <EOL> assert s . row [ "<STR_LIT>" ] == [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" ] <EOL> assert s . row [ "<STR_LIT>" ] == [ "<STR_LIT:4>" , "<STR_LIT:5>" , "<STR_LIT>" ] <EOL> @ raises ( IndexError ) <EOL> def test_formatter_by_named_column3 ( self ) : <EOL> """<STR_LIT>""" <EOL> pe . formatters . NamedRowFormatter ( [ "<STR_LIT>" , <NUM_LIT:1> ] , str ) <EOL> @ raises ( IndexError ) <EOL> def test_empty_list_in_named_row_column ( self ) : <EOL> pe . formatters . NamedRowFormatter ( [ ] , str ) <EOL> @ raises ( NotImplementedError ) <EOL> def test_float_in_list_in_named_formatter ( self ) : <EOL> pe . formatters . NamedRowFormatter ( <NUM_LIT> , str ) <EOL> def test_add ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> data = OrderedDict ( { <EOL> "<STR_LIT>" : [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> ] <EOL> } <EOL> ) <EOL> s = s . row + data <EOL> assert s . row [ "<STR_LIT>" ] == [ <NUM_LIT:10> , <NUM_LIT:11> , <NUM_LIT:12> ] <EOL> @ raises ( TypeError ) <EOL> def test_add_wrong_type ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> s = s . row + "<STR_LIT>" <EOL> @ raises ( ValueError ) <EOL> def test_delete_named_row ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> del s . row [ "<STR_LIT>" ] <EOL> assert s . number_of_rows ( ) == <NUM_LIT:3> <EOL> s . row [ "<STR_LIT>" ] <EOL> @ raises ( ValueError ) <EOL> def test_delete_indexed_row1 ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> del s . row [ <NUM_LIT:2> ] <EOL> assert s . number_of_rows ( ) == <NUM_LIT:3> <EOL> s . row [ "<STR_LIT>" ] <EOL> @ raises ( ValueError ) <EOL> def test_delete_indexed_row2 ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> s . delete_named_row_at ( <NUM_LIT:2> ) <EOL> assert s . number_of_rows ( ) == <NUM_LIT:3> <EOL> s . row [ "<STR_LIT>" ] <EOL> def test_set_named_row ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" ) <EOL> s . name_rows_by_column ( <NUM_LIT:0> ) <EOL> s . row [ "<STR_LIT>" ] = [ <NUM_LIT:11> , <NUM_LIT:11> , <NUM_LIT:11> ] <EOL> assert s . row [ "<STR_LIT>" ] == [ <NUM_LIT:11> , <NUM_LIT:11> , <NUM_LIT:11> ] <EOL> def test_set_indexed_column ( self ) : <EOL> s = pe . sheets . NominableSheet ( self . data , "<STR_LIT:test>" , name_rows_by_column = <NUM_LIT:0> ) <EOL> s . column [ <NUM_LIT:0> ] = [ <NUM_LIT:12> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] <EOL> assert s . column [ <NUM_LIT:0> ] == [ <NUM_LIT:12> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] <EOL> class TestUniquenessOfNames : <EOL> def test_column_names ( self ) : <EOL> data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] <EOL> ] <EOL> sheet = pe . Sheet ( data , name_columns_by_row = <NUM_LIT:2> ) <EOL> assert sheet . colnames == [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def test_column_names2 ( self ) : <EOL> data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> [ <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] <EOL> ] <EOL> sheet = pe . Sheet ( data ) <EOL> sheet . colnames = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> assert sheet . colnames == [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def test_row_names ( self ) : <EOL> data = [ <EOL> [ "<STR_LIT>" , - <NUM_LIT:1> , - <NUM_LIT:2> , - <NUM_LIT:3> ] , <EOL> [ "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <EOL> [ "<STR_LIT>" , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> [ "<STR_LIT>" , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] <EOL> ] <EOL> sheet = pe . Sheet ( data , name_rows_by_column = <NUM_LIT:0> ) <EOL> assert sheet . rownames == [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def test_row_names2 ( self ) : <EOL> data = [ <EOL> [ - <NUM_LIT:1> , - <NUM_LIT:2> , - <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , <EOL> [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] , <EOL> [ <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> ] <EOL> ] <EOL> sheet = pe . Sheet ( data ) <EOL> sheet . rownames = [ "<STR_LIT>" ] * <NUM_LIT:4> <EOL> assert sheet . rownames == [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> class TestSheetRegion : <EOL> def test_region ( self ) : <EOL> data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ] <EOL> s = pe . Sheet ( data ) <EOL> data = s . region ( [ <NUM_LIT:1> , <NUM_LIT:1> ] , [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> expected = [ <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ] <EOL> assert data == expected <EOL> def test_cut_region ( self ) : <EOL> data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ] <EOL> s = pe . Sheet ( data ) <EOL> data = s . cut ( [ <NUM_LIT:1> , <NUM_LIT:1> ] , [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> expected = [ <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ] <EOL> expected2 = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] , <EOL> [ <NUM_LIT> , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ] <EOL> assert data == expected <EOL> assert s . to_array ( ) == expected2 <EOL> def test_cut_and_paste_region ( self ) : <EOL> data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ] <EOL> s = pe . Sheet ( data ) <EOL> data = s . cut ( [ <NUM_LIT:1> , <NUM_LIT:1> ] , [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> s . paste ( [ <NUM_LIT:0> , <NUM_LIT:0> ] , rows = data ) <EOL> expected = [ <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] , <EOL> [ <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ] <EOL> assert expected == s . to_array ( ) <EOL> def test_cut_and_paste_region_within_limits_at_edge ( self ) : <EOL> data = [ <EOL> [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ] <EOL> s = pe . Sheet ( data ) <EOL> data = s . cut ( [ <NUM_LIT:1> , <NUM_LIT:1> ] , [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> s . paste ( [ <NUM_LIT:0> , <NUM_LIT:0> ] , rows = data ) <EOL> expected = [ <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> ] , <EOL> [ <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ] <EOL> assert expected == s . to_array ( ) <EOL> class TestLoadingFunction : <EOL> def test_load_from_dict ( self ) : <EOL> content = { <EOL> "<STR_LIT:a>" : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:5> ] , <EOL> "<STR_LIT:b>" : [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> ] <EOL> } <EOL> sheet = pe . load_from_dict ( content , name_columns_by_row = <NUM_LIT:0> ) <EOL> assert sorted ( sheet . colnames ) == sorted ( content . keys ( ) ) <EOL> def test_load_from_records ( self ) : <EOL> content = [ <EOL> { "<STR_LIT:a>" : <NUM_LIT:1> , "<STR_LIT:b>" : <NUM_LIT:2> } , <EOL> { "<STR_LIT:a>" : <NUM_LIT:3> , "<STR_LIT:b>" : <NUM_LIT:4> } <EOL> ] <EOL> sheet = pe . load_from_records ( content , name_columns_by_row = <NUM_LIT:0> ) <EOL> expected = { <EOL> "<STR_LIT:a>" : [ <NUM_LIT:1> , <NUM_LIT:3> ] , <EOL> "<STR_LIT:b>" : [ <NUM_LIT:2> , <NUM_LIT:4> ] <EOL> } <EOL> assert sheet . to_dict ( ) == expected </s>
