def test_dataframemodel_sort(): """Validate the data in the model.""" df = DataFrame({'colA': [1, 3], 'colB': ['c', 'a']}) dfm = DataFrameModel(df) dfm.sort(1) assert data(dfm, 0, 0) == '3' assert data(dfm, 1, 0) == '1' assert data(dfm, 0, 1) == 'a' assert data(dfm, 1, 1) == 'c'
def test_dataframemodel_sort(): """Validate the data in the model.""" df = DataFrame({'colA': [1, 3], 'colB': ['c', 'a']}) dfm = DataFrameModel(df) dfm.sort(1) assert data(dfm, 0, 0) == '3' assert data(dfm, 1, 0) == '1' assert data(dfm, 0, 1) == 'a' assert data(dfm, 1, 1) == 'c'
def test_dataframemodel_sort_is_stable(): # cf. issue 3010 """Validate the sort function.""" df = DataFrame([[2,14], [2,13], [2,16], [1,3], [2,9], [1,15], [1,17], [2,2], [2,10], [1,6], [2,5], [2,8], [1,11], [1,1], [1,12], [1,4], [2,7]]) dfm = DataFrameModel(df) dfm.sort(1) dfm.sort(0) col2 = [data(dfm, i, 1) for i in range(len(df))] assert col2 == [str(x) for x in [1, 3, 4, 6, 11, 12, 15, 17, 2, 5, 7, 8, 9, 10, 13, 14, 16]]
def test_dataframemodel_sort_is_stable(): # cf. spyder-ide/spyder#3010. """Validate the sort function.""" df = DataFrame([[2,14], [2,13], [2,16], [1,3], [2,9], [1,15], [1,17], [2,2], [2,10], [1,6], [2,5], [2,8], [1,11], [1,1], [1,12], [1,4], [2,7]]) dfm = DataFrameModel(df) dfm.sort(1) dfm.sort(0) col2 = [data(dfm, i, 1) for i in range(len(df))] assert col2 == [str(x) for x in [1, 3, 4, 6, 11, 12, 15, 17, 2, 5, 7, 8, 9, 10, 13, 14, 16]]