From 6c5a88ecd89cb6db70e409ac6ad06fae32c3a9f2 Mon Sep 17 00:00:00 2001 From: Mike Kryjak Date: Fri, 6 Mar 2026 12:02:11 +0000 Subject: [PATCH 1/2] Fix grid name parsing If passed with quotation marks, these are stripped in BOUT++ but not here, causing issues on load --- src/boutdata/data.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/boutdata/data.py b/src/boutdata/data.py index d3fbd3c54..bb350a7de 100644 --- a/src/boutdata/data.py +++ b/src/boutdata/data.py @@ -743,8 +743,12 @@ def count_brackets(s): # Try to convert to float value = float(value) except ValueError: - # Leave as a string - pass + # Leave as a string, stripping surrounding quotes + if len(value) >= 2 and ( + (value[0] == '"' and value[-1] == '"') + or (value[0] == "'" and value[-1] == "'") + ): + value = value[1:-1] value_name = line[:eqpos].strip() section[value_name] = value From 61fc9917fa54035f2a0613976098b1389b9295d3 Mon Sep 17 00:00:00 2001 From: Mike Kryjak Date: Fri, 6 Mar 2026 12:16:19 +0000 Subject: [PATCH 2/2] Make recalculate_xyz optional This is rarely needed, but requires either grid size data or the grid file, making it expensive and cause warnings if neither are available. --- src/boutdata/data.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/boutdata/data.py b/src/boutdata/data.py index bb350a7de..b72e1d47f 100644 --- a/src/boutdata/data.py +++ b/src/boutdata/data.py @@ -639,6 +639,7 @@ def __init__( nx=None, ny=None, nz=None, + recalculate_xyz=True, ): BoutOptions.__init__(self, name) self.filename = filename @@ -759,15 +760,16 @@ def count_brackets(s): section.inline_comments[value_name] = inline_comment section._comment_whitespace[value_name] = comment_whitespace - try: - self.recalculate_xyz(nx=nx, ny=ny, nz=nz) - except Exception as e: - alwayswarn( - "While building x, y, z coordinate arrays, an " - "exception occured: " - + str(e) - + "\nEvaluating non-scalar options not available" - ) + if recalculate_xyz: + try: + self.recalculate_xyz(nx=nx, ny=ny, nz=nz) + except Exception as e: + alwayswarn( + "While building x, y, z coordinate arrays, an " + "exception occured: " + + str(e) + + "\nEvaluating non-scalar options not available" + ) def recalculate_xyz(self, *, nx=None, ny=None, nz=None): """