Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/boutdata/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ def __init__(
nx=None,
ny=None,
nz=None,
recalculate_xyz=True,
):
BoutOptions.__init__(self, name)
self.filename = filename
Expand Down Expand Up @@ -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
Expand All @@ -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):
"""
Expand Down
Loading