def test_sort_collectionsmodel_with_many_rows(): coll = list(range(2*LARGE_NROWS)) cm = CollectionsModel(None, coll) assert cm.rowCount() == cm.rows_loaded == ROWS_TO_LOAD assert cm.columnCount() == 5 cm.sort(1) # This was causing an issue (#5232) cm.fetchMore() assert cm.rowCount() == 2 * ROWS_TO_LOAD for _ in range(3): cm.fetchMore() assert cm.rowCount() == len(coll)
def test_sort_collectionsmodel_with_many_rows(): coll = list(range(2*LARGE_NROWS)) cm = CollectionsModel(None, coll) assert cm.rowCount() == cm.rows_loaded == ROWS_TO_LOAD assert cm.columnCount() == 4 cm.sort(1) # This was causing an issue (#5232) cm.fetchMore() assert cm.rowCount() == 2 * ROWS_TO_LOAD for _ in range(3): cm.fetchMore() assert cm.rowCount() == len(coll)
def test_sort_collectionsmodel(): coll = [1, 3, 2] cm = CollectionsModel(None, coll) assert cm.rowCount() == 3 assert cm.columnCount() == 4 cm.sort(0) # sort by index assert data_table(cm, 3, 4) == [['0', '1', '2'], ['int', 'int', 'int'], ['1', '1', '1'], ['1', '3', '2']] cm.sort(3) # sort by value assert data_table(cm, 3, 4) == [['0', '2', '1'], ['int', 'int', 'int'], ['1', '1', '1'], ['1', '2', '3']] coll = [[1, 2], 3] cm = CollectionsModel(None, coll) assert cm.rowCount() == 2 assert cm.columnCount() == 4 cm.sort(1) # sort by type assert data_table(cm, 2, 4) == [['1', '0'], ['int', 'list'], ['1', '2'], ['3', '[1, 2]']] cm.sort(2) # sort by size assert data_table(cm, 2, 4) == [['1', '0'], ['int', 'list'], ['1', '2'], ['3', '[1, 2]']]
def test_sort_collectionsmodel(): var_list1 = [0, 1, 2] var_list2 = [3, 4, 5, 6] var_dataframe1 = pandas.DataFrame([[1, 2, 3], [20, 30, 40], [2, 2, 2]]) var_dataframe2 = pandas.DataFrame([[1, 2, 3], [20, 30, 40]]) var_series1 = pandas.Series(var_list1) var_series2 = pandas.Series(var_list2) coll = [1, 3, 2] cm = CollectionsModel(None, coll) assert cm.rowCount() == 3 assert cm.columnCount() == 5 cm.sort(0) # sort by index assert data_table(cm, 3, 4) == [[0, 1, 2], ['int', 'int', 'int'], [1, 1, 1], ['1', '3', '2']] cm.sort(3) # sort by value assert data_table(cm, 3, 4) == [[0, 2, 1], ['int', 'int', 'int'], [1, 1, 1], ['1', '2', '3']] coll = [1, var_list1, var_list2, var_dataframe1, var_dataframe2, var_series1, var_series2] cm = CollectionsModel(None, coll) assert cm.rowCount() == 7 assert cm.columnCount() == 5 cm.sort(1) # sort by type assert data_table(cm, 7, 4) == [ [3, 4, 5, 6, 0, 1, 2], ['DataFrame', 'DataFrame', 'Series', 'Series', 'int', 'list', 'list'], ['(3, 3)', '(2, 3)', '(3,)', '(4,)', 1, 3, 4], ['Column names: 0, 1, 2', 'Column names: 0, 1, 2', 'Series object of pandas.core.series module', 'Series object of pandas.core.series module', '1', '[0, 1, 2]', '[3, 4, 5, 6]']] cm.sort(2) # sort by size assert data_table(cm, 7, 4) == [ [3, 4, 5, 6, 0, 1, 2], ['DataFrame', 'DataFrame', 'Series', 'Series', 'int', 'list', 'list'], ['(2, 3)', '(3,)', '(3, 3)', '(4,)', 1, 3, 4], ['Column names: 0, 1, 2', 'Column names: 0, 1, 2', 'Series object of pandas.core.series module', 'Series object of pandas.core.series module', '1', '[0, 1, 2]', '[3, 4, 5, 6]']] or data_table(cm, 7, 4) == [ [0, 1, 2, 4, 5, 3, 6], [u'int', u'list', u'list', u'DataFrame', u'Series', u'DataFrame', u'Series'], [1, 3, 4, u'(2, 3)', u'(3,)', u'(3, 3)', u'(4,)'], ['1', '[0, 1, 2]', '[3, 4, 5, 6]', 'Column names: 0, 1, 2', 'Series object of pandas.core.series module', 'Column names: 0, 1, 2', 'Series object of pandas.core.series module', ]]