Skip to content

Commit

Permalink
Handle empty cells in default sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj committed Oct 9, 2024
1 parent ac0dc15 commit 9567649
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ert/config/design_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,23 @@ def _read_defaultssheet(
return {}
if len(default_df.columns) < 2:
raise ValueError("Defaults sheet must have at least two columns")
empty_cells = [
f"Row {default_df.index[i]}, column {default_df.columns[j]}"
for i, j in zip(*np.where(pd.isna(default_df)))
]
if empty_cells > 0:
raise ValueError(f"Default sheet contains empty cells {empty_cells}")
# Look for initial or trailing whitespace in parameter names. This
# is disallowed as it can create user confusion and has no use-case.
whitespace_errors = []
for paramname in default_df.loc[:, 0]:
if paramname != paramname.strip():
raise ValueError(
whitespace_errors.append(
f"Parameter name '{paramname}' in default values contains "
"initial or trailing whitespace."
)
if whitespace_errors > 0:
raise ValueError(whitespace_errors)

return {row[0]: convert_to_numeric(row[1]) for _, row in default_df.iterrows()}

Expand Down

0 comments on commit 9567649

Please sign in to comment.