Skip to content

Commit 376e932

Browse files
Read list param values in less-brokenly
1 parent c87b4cb commit 376e932

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/geophires_x/GeoPHIRESUtils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def read_input_file(return_dict_1, logger=None, input_file_name=None):
554554
comment = comment + elements[i]
555555

556556
# done with parsing, now create the object and add to the dictionary
557-
p_entry = ParameterEntry(description, s_val, comment)
557+
p_entry = ParameterEntry(description, s_val, comment, line)
558558
return_dict_1[description] = p_entry # make the dictionary element
559559

560560
else:

src/geophires_x/Parameter.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ParameterEntry:
4343
Name: str
4444
sValue: str
4545
Comment: Optional[str] = None
46+
raw_entry: Optional[str] = None
4647

4748

4849
@dataclass
@@ -373,13 +374,17 @@ def default_parameter_value_message(new_val: Any, param_to_modify_name: str, def
373374
# All is good. With a list, we have to use the last character of the Description to get the position.
374375
# I.e., "Gradient 1" should yield a position = 0 ("1" - 1)
375376
else:
376-
parts = ParameterReadIn.Name.split(' ')
377-
position = int(parts[1]) - 1
378-
if position >= len(ParamToModify.value):
379-
ParamToModify.value.append(New_val) # we are adding to the list, so use append
380-
else: # we are replacing a value, so pop the value we want to replace, then insert a new one
381-
ParamToModify.value.pop(position)
382-
ParamToModify.value.insert(position, New_val)
377+
if ' ' in ParamToModify.Name:
378+
parts = ParameterReadIn.Name.split(' ')
379+
position = int(parts[1]) - 1
380+
if position >= len(ParamToModify.value):
381+
ParamToModify.value.append(New_val) # we are adding to the list, so use append
382+
else: # we are replacing a value, so pop the value we want to replace, then insert a new one
383+
ParamToModify.value.pop(position)
384+
ParamToModify.value.insert(position, New_val)
385+
else:
386+
ParamToModify.value = [float(x.strip()) for x in ParameterReadIn.raw_entry.split('--')[0].split(',')[1:]
387+
if x.strip() != '']
383388
elif isinstance(ParamToModify, boolParameter):
384389
if ParameterReadIn.sValue == "0":
385390
New_val = False

0 commit comments

Comments
 (0)