Skip to content

Commit 1c23286

Browse files
committed
refactor(viz_utils)
1 parent 801abb4 commit 1c23286

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

element_moseq/plotting/viz_utils.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -352,26 +352,22 @@ def copy_pdf_to_png(project_dir, model_name):
352352
FileNotFoundError: If the PDF file doesn't exist
353353
RuntimeError: If conversion fails
354354
"""
355-
try:
356-
from pdf2image import convert_from_path
355+
from pdf2image import convert_from_path
357356

358-
# Construct paths for PDF and PNG files
359-
model_dir = Path(project_dir) / model_name
360-
pdf_path = model_dir / "fitting_progress.pdf"
361-
png_path = model_dir / "fitting_progress.png"
357+
# Construct paths for PDF and PNG files
358+
model_dir = Path(project_dir) / model_name
359+
pdf_path = model_dir / "fitting_progress.pdf"
360+
png_path = model_dir / "fitting_progress.png"
362361

363-
# Check if PDF exists
364-
if not pdf_path.exists():
365-
raise FileNotFoundError(f"PDF progress plot not found at {pdf_path}")
362+
# Check if PDF exists
363+
if not pdf_path.exists():
364+
raise FileNotFoundError(f"PDF progress plot not found at {pdf_path}")
366365

367-
# Convert PDF to PNG
368-
images = convert_from_path(pdf_path, dpi=300)
369-
if not images:
370-
raise ValueError(f"No PDF file found at {pdf_path}")
366+
# Convert PDF to PNG
367+
images = convert_from_path(pdf_path, dpi=300)
368+
if not images:
369+
raise ValueError(f"No PDF file found at {pdf_path}")
371370

372-
images[0].save(png_path, "PNG")
373-
logger.info(f"Generated PNG progress plot at {png_path}")
374-
return True
375-
376-
except Exception as e:
377-
raise RuntimeError(f"Failed to convert PDF to PNG: {e}")
371+
images[0].save(png_path, "PNG")
372+
logger.info(f"Generated PNG progress plot at {png_path}")
373+
return True

0 commit comments

Comments
 (0)