From bd4a4a08e544f5c4df6dbafa4213e5c75cdfe86b Mon Sep 17 00:00:00 2001 From: Gerard Talatinian <68045466+gerardvt@users.noreply.github.com> Date: Thu, 26 Mar 2026 06:02:37 -0400 Subject: [PATCH] fix: lazy imports for matplotlib & gdstk (#161) only require matplotlib & gdstk for functionality where we actually use them contributed by @gerardvt --- doc_utils.py | 3 ++- render_utils.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc_utils.py b/doc_utils.py index 765676f..6b9018b 100644 --- a/doc_utils.py +++ b/doc_utils.py @@ -5,7 +5,6 @@ import subprocess from typing import Optional import chevron -import matplotlib as mpl from config import Config, DatasheetConfig @@ -29,6 +28,8 @@ class DocsHelper: """ Format the clock with engineering notation """ + import matplotlib as mpl + if clock == 0: return "No Clock" else: diff --git a/render_utils.py b/render_utils.py index ef2855c..3623c0d 100644 --- a/render_utils.py +++ b/render_utils.py @@ -5,7 +5,6 @@ import re import subprocess import cairosvg # type: ignore -import gdstk # type: ignore # Custom exception for convert_svg_to_png() @@ -35,6 +34,8 @@ def render_svg( filter_layers=None, scramble_cells=None, ): + import gdstk # type: ignore + library = gdstk.read_gds(gds) top_cells = library.top_level() assert len(top_cells) == 1