From a844b14f20f73ce87103c831e591c6e9dd446e18 Mon Sep 17 00:00:00 2001 From: Manuel Huber Date: Mon, 9 Sep 2024 20:29:07 +0200 Subject: [PATCH] Make docs build happe --- src/legendoptics/pyg4utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/legendoptics/pyg4utils.py b/src/legendoptics/pyg4utils.py index 61bc51e..a06396a 100644 --- a/src/legendoptics/pyg4utils.py +++ b/src/legendoptics/pyg4utils.py @@ -167,10 +167,12 @@ def addConstPropertyPint(self, name, value): g4.solid.OpticalSurface.addConstPropertyPint = addConstPropertyPint # those units are supported by G4, but not by pyg4ometry... - if "nanometer" not in gdml_u.units: - gdml_u.units["nanometer"] = gdml_u.units["nm"] - if "micrometer" not in gdml_u.units: - gdml_u.units["micrometer"] = gdml_u.units["um"] + # the first check is ugly, but necessary: we have a mock import of gdml_u for the docs build. + if isinstance(gdml_u.units, dict): + if "nanometer" not in gdml_u.units: + gdml_u.units["nanometer"] = gdml_u.units["nm"] + if "micrometer" not in gdml_u.units: + gdml_u.units["micrometer"] = gdml_u.units["um"] _patch_g4_pint_unit_support()