Skip to content

Commit 09c876b

Browse files
committed
Speed up a test
1 parent 9a2d9ea commit 09c876b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pandas/io/formats/csvs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
from pandas.io.formats.format import DataFrameFormatter
4545

4646

47+
_DEFAULT_CHUNKSIZE_CELLS = 100_000
48+
49+
4750
class CSVFormatter:
4851
cols: np.ndarray
4952

@@ -162,7 +165,7 @@ def _initialize_columns(self, cols: Sequence[Hashable] | None) -> np.ndarray:
162165

163166
def _initialize_chunksize(self, chunksize: int | None) -> int:
164167
if chunksize is None:
165-
return (100000 // (len(self.cols) or 1)) or 1
168+
return (_DEFAULT_CHUNKSIZE_CELLS // (len(self.cols) or 1)) or 1
166169
return int(chunksize)
167170

168171
@property

pandas/tests/frame/methods/test_to_csv.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,11 @@ def test_to_csv_chunking(self, chunksize):
759759
tm.assert_frame_equal(rs, aa)
760760

761761
@pytest.mark.slow
762-
def test_to_csv_wide_frame_formatting(self):
762+
def test_to_csv_wide_frame_formatting(self, monkeypatch):
763763
# Issue #8621
764-
df = DataFrame(np.random.randn(1, 100010), columns=None, index=None)
764+
n_cells = 1_000
765+
monkeypatch.setattr("pandas.io.formats.csvs._DEFAULT_CHUNKSIZE_CELLS", n_cells)
766+
df = DataFrame(np.random.randn(1, n_cells + 10), columns=None, index=None)
765767
with tm.ensure_clean() as filename:
766768
df.to_csv(filename, header=False, index=False)
767769
rs = read_csv(filename, header=None)

0 commit comments

Comments
 (0)