diff --git a/src/boutdata/data.py b/src/boutdata/data.py index d3fbd3c54..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 @@ -743,8 +744,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 @@ -755,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): """