Skip to content

Commit 6623121

Browse files
committed
FIX-#7671: Fix transfer message truncating on larger sizes
Signed-off-by: Jonathan Shi <[email protected]>
1 parent 954550a commit 6623121

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

modin/pandas/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4531,7 +4531,7 @@ def set_backend(
45314531
max_shape_str = f"({max_rows:.0g}, {max_cols:.0g})"
45324532
desc = (
45334533
f"Transfer: {self_backend_str:>10.10}{normalized_backend_str:<10.10} "
4534-
+ f" | {operation_str:^15.15}{max_shape_str:<10.10}"
4534+
+ f" | {operation_str:^15.15}{max_shape_str}"
45354535
)
45364536

45374537
if ShowBackendSwitchProgress.get():

modin/tests/pandas/test_backend.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,20 @@ def test_fallback_progress_printing(
447447
assert captured.out == "" # Nothing should go to stdout
448448

449449

450+
@config_context(Backend="python_test")
451+
def test_bigger_df_progress_message():
452+
# Insiginificant digits in the size get truncated
453+
df = pd.DataFrame([[1] * 144] * 121)
454+
with patch.object(tqdm.auto, "trange", return_value=range(2)) as mock_trange:
455+
df.set_backend("pandas")
456+
mock_trange.assert_called_once()
457+
call_args = mock_trange.call_args
458+
desc = call_args[1]["desc"] # Get the 'desc' keyword argument
459+
assert desc.startswith(
460+
"Transfer: Python_... → Pandas | ≃ (1e+02, 1e+02)"
461+
)
462+
463+
450464
@patch("tqdm.auto.trange", side_effect=ImportError("tqdm not available"))
451465
@config_context(Backend="python_test")
452466
def test_fallback_progress_printing_silent_when_disabled(mock_trange, capsys):

0 commit comments

Comments
 (0)