示例#1
0
    def testFetchDataFrameCornerData(self):
        max_rows = pd.get_option('display.max_rows')
        try:
            min_rows = pd.get_option('display.min_rows')
        except KeyError:  # pragma: no cover
            min_rows = max_rows
        sess = new_session()

        for row in (5,
                    max_rows - 2,
                    max_rows - 1,
                    max_rows,
                    max_rows + 1,
                    max_rows + 2,
                    max_rows + 3):
            pdf = pd.DataFrame(np.random.rand(row, 5))
            df = DataFrame(pdf, chunk_size=max_rows // 2)
            sess.run(df, fetch=False)

            corner = fetch_corner_data(df, session=sess)
            self.assertLessEqual(corner.shape[0], max_rows + 2)
            corner_max_rows = max_rows if row <= max_rows else corner.shape[0] - 1
            self.assertEqual(corner.to_string(max_rows=corner_max_rows, min_rows=min_rows),
                             pdf.to_string(max_rows=max_rows, min_rows=min_rows),
                             'failed when row == {}'.format(row))
示例#2
0
def test_fetch_dataframe_corner_data(setup):
    max_rows = pd.get_option('display.max_rows')
    try:
        min_rows = pd.get_option('display.min_rows')
    except KeyError:  # pragma: no cover
        min_rows = max_rows

    for row in (5, max_rows - 2, max_rows - 1, max_rows, max_rows + 1,
                max_rows + 2, max_rows + 3):
        pdf = pd.DataFrame(np.random.rand(row, 5))
        df = DataFrame(pdf, chunk_size=max_rows // 2)
        df.execute()

        corner = fetch_corner_data(df)
        assert corner.shape[0] <= max_rows + 2
        corner_max_rows = max_rows if row <= max_rows else corner.shape[0] - 1
        assert corner.to_string(max_rows=corner_max_rows,
                                min_rows=min_rows) == pdf.to_string(
                                    max_rows=max_rows, min_rows=min_rows)