def test_tabulator_pagination_selection(document, comm): df = makeMixedDataFrame() table = Tabulator(df, pagination='remote', page_size=2) model = table.get_root(document, comm) table.selection = [2, 3] assert model.source.selected.indices == [] table.page = 2 assert model.source.selected.indices == [0, 1]
def test_tabulator_pagination_selectable_rows(document, comm): df = makeMixedDataFrame() table = Tabulator(df, pagination='remote', page_size=3, selectable_rows=lambda df: list(df.index.values[::2])) model = table.get_root(document, comm) print(table._processed) assert model.selectable_rows == [0, 2] table.page = 2 assert model.selectable_rows == [3]
def test_tabulator_expanded_content_pagination(): df = makeMixedDataFrame() table = Tabulator(df, expanded=[0, 1], row_content=lambda r: r.A, pagination='remote', page_size=2) model = table.get_root() assert len(model.children) == 2 table.page = 2 assert len(model.children) == 0
def test_tabulator_pagination(document, comm): df = makeMixedDataFrame() table = Tabulator(df, pagination='remote', page_size=2) model = table.get_root(document, comm) assert model.max_page == 3 assert model.page_size == 2 assert model.page == 1 expected = { 'index': np.array([0, 1]), 'A': np.array([0, 1]), 'B': np.array([0, 1]), 'C': np.array(['foo1', 'foo2']), 'D': np.array( ['2009-01-01T00:00:00.000000000', '2009-01-02T00:00:00.000000000'], dtype='datetime64[ns]').astype(np.int64) / 10e5 } for col, values in model.source.data.items(): np.testing.assert_array_equal(values, expected[col]) table.page = 2 expected = { 'index': np.array([2, 3]), 'A': np.array([2, 3]), 'B': np.array([0., 1.]), 'C': np.array(['foo3', 'foo4']), 'D': np.array( ['2009-01-05T00:00:00.000000000', '2009-01-06T00:00:00.000000000'], dtype='datetime64[ns]').astype(np.int64) / 10e5 } for col, values in model.source.data.items(): np.testing.assert_array_equal(values, expected[col]) table.page_size = 3 table.page = 1 assert model.max_page == 2 expected = { 'index': np.array([0, 1, 2]), 'A': np.array([0, 1, 2]), 'B': np.array([0, 1, 0]), 'C': np.array(['foo1', 'foo2', 'foo3']), 'D': np.array([ '2009-01-01T00:00:00.000000000', '2009-01-02T00:00:00.000000000', '2009-01-05T00:00:00.000000000' ], dtype='datetime64[ns]').astype(np.int64) / 10e5 } for col, values in model.source.data.items(): np.testing.assert_array_equal(values, expected[col])