Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
steinnymir committed Oct 25, 2023
1 parent babc325 commit 09b2dad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sed/calibrator/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,10 @@ def apply_energy_offset(
print(msg)
else:
# use passed parameters
if columns is not None and (signs is None or subtract_mean is None):
raise ValueError(
"If columns is passed, signs and subtract_mean must also be passed.",
)
if isinstance(columns, str):
columns = [columns]
if isinstance(signs, int):
Expand All @@ -1530,6 +1534,10 @@ def apply_energy_offset(
# flip sign for binding energy scale
energy_scale = self.get_current_calibration().get("energy_scale", None)
if energy_scale == "binding":
if None in signs:
raise ValueError(
"Cannot apply binding energy offset to columns with unknown sign.",
)
signs = [-s for s in signs]
elif energy_scale == "kinetic":
pass
Expand Down
2 changes: 2 additions & 0 deletions sed/core/dfops.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ def apply_offset_from_columns(
signs = [signs]
if len(signs) != len(offset_columns):
raise ValueError("signs and offset_columns must have the same length!")
if isinstance(subtract_mean, bool):
subtract_mean = [subtract_mean] * len(offset_columns)

for col, sign, red, submean in zip(offset_columns, signs, reductions, subtract_mean):
assert col in df.columns, f"{col} not in dataframe!"
Expand Down

0 comments on commit 09b2dad

Please sign in to comment.