Skip to content

Commit

Permalink
Use pandas to check for duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeda committed Nov 19, 2024
1 parent f2f1054 commit 23ccbe9
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/fmu/tools/sensitivities/_excel2dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,15 @@ def _find_onebyone_input_sheet(input_filename):

def _check_designinput(dsgn_input):
"""Checks for valid input in designinput sheet"""

# Check for duplicate sensnames
sensitivity_names = []
for row in dsgn_input.itertuples():
if _has_value(row.sensname):
if row.sensname in sensitivity_names:
raise ValueError(
"sensname '{}' was found on more than one row in designinput "
"sheet. Two sensitivities can not share the same sensname. "
"Please correct this and rerun".format(row.sensname)
)
sensitivity_names.append(row.sensname)
duplicates = dsgn_input[dsgn_input["sensname"].notna()]["sensname"].duplicated()
if duplicates.any():
duplicate_names = dsgn_input.loc[duplicates, "sensname"].values
raise ValueError(
f"sensname '{duplicate_names[0]}' was found on more than one row in "
f"designinput sheet. Two sensitivities can not share the same "
f"sensname. Please correct this and rerun"
)


def _check_for_mixed_sensitivities(sens_name, sens_group):
Expand Down

0 comments on commit 23ccbe9

Please sign in to comment.