From 63a94c73026c9f0fc242f2c28665912973335156 Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Fri, 25 Oct 2024 11:02:16 +0200 Subject: [PATCH] fix: don't assume log has value field --- src/chexus/validators.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/chexus/validators.py b/src/chexus/validators.py index 4dc0201..55fa2de 100644 --- a/src/chexus/validators.py +++ b/src/chexus/validators.py @@ -244,10 +244,15 @@ def validate(self, node: Dataset | Group) -> Violation | None: import scipp as sc rotation_speed = node.children.get("rotation_speed") - if "NXlog" == rotation_speed.attrs.get("NX_class"): - unit = rotation_speed.children.get("value").attrs.get("units") - else: + if ( + "NXlog" == rotation_speed.attrs.get("NX_class") + and "value" in rotation_speed.children + ): + unit = rotation_speed.children["value"].attrs.get("units") + elif "NXlog" != rotation_speed.attrs.get("NX_class"): unit = rotation_speed.attrs.get("units") + else: + return try: sc.scalar(1, unit=unit).to(unit="Hz") except sc.UnitError: