From 3ba505d337692560d2675c0c065793427b29f981 Mon Sep 17 00:00:00 2001 From: James McClung Date: Wed, 20 May 2026 15:21:03 -0400 Subject: [PATCH] animated_plot: only log \r for tty --- src/lib/plotting/animated_plot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/plotting/animated_plot.py b/src/lib/plotting/animated_plot.py index e39fda96..f17d4ebf 100644 --- a/src/lib/plotting/animated_plot.py +++ b/src/lib/plotting/animated_plot.py @@ -1,5 +1,6 @@ from __future__ import annotations +import sys from pathlib import Path import matplotlib.pyplot as plt @@ -13,7 +14,8 @@ def print_progress(current_frame: int, n_frames: int): current_frame_padded = str(current_frame + 1).rjust(len(str(n_frames))) - print(f"frame {current_frame_padded}/{n_frames}", end="\r") + end = "\r" if sys.stdout.isatty() else "\n" + print(f"frame {current_frame_padded}/{n_frames}", end=end) class AnimatedPlot[Data: DataWithAttrs](Plot[Data]):