Skip to content

Commit

Permalink
fix linting and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
steinnymir committed Oct 19, 2023
1 parent 006921c commit 208c5a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 5 additions & 6 deletions sed/calibrator/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,6 @@ def tof2ns(
x: Union[List[float], np.ndarray],
tof_binwidth: float,
tof_binning: int,
dtype: type = np.float64,
) -> Union[List[float], np.ndarray]:
"""Converts the time-of-flight steps to time-of-flight in nanoseconds.
Expand All @@ -2162,8 +2161,8 @@ def tof2ns(
Returns:
Union[pd.DataFrame, dask.dataframe.DataFrame]: Dataframe with the new column.
"""
val = x.astype(dtype) * tof_binwidth * 2**tof_binning
return val.astype(dtype)
val = x * tof_binwidth * 2**tof_binning
return val


def apply_energy_offset(
Expand Down Expand Up @@ -2201,9 +2200,9 @@ def apply_energy_offset(
signs = [signs]
if reductions is None:
reductions = [None] * len(columns)
columns_ = []
reductions_ = []
to_roll = []
columns_: Sequence[str] = []
reductions_: Sequence[str] = []
to_roll: Sequence[str] = []

for c, r in zip(columns, reductions):
if r == "rolled":
Expand Down
1 change: 1 addition & 0 deletions sed/loader/flash/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Helper functions for the flash loader."""
from typing import Union

import dask.dataframe
Expand Down
9 changes: 7 additions & 2 deletions tests/loader/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Module tests.loader.test_utils, tests for the sed.load.utils file
"""
import dask.dataframe as dd
import numpy as np
import pandas as pd
Expand All @@ -13,7 +15,8 @@


@pytest.fixture
def input_df():
def input_df(): # pylint: disable=redefined-outer-name
"""Fixture for input dataframe"""
return pd.DataFrame(
{
"input_column": [0, 1, 2, 3, 4, 5, 6, 7],
Expand All @@ -22,6 +25,7 @@ def input_df():


def test_split_channel_bitwise(input_df):
"""Test split_channel_bitwise function"""
output_columns = ["output1", "output2"]
bit_mask = 2
expected_output = pd.DataFrame(
Expand All @@ -37,6 +41,7 @@ def test_split_channel_bitwise(input_df):


def test_split_channel_bitwise_raises():
"""Test split_channel_bitwise function raises"""
pytest.raises(
KeyError,
split_channel_bitwise,
Expand Down Expand Up @@ -77,7 +82,7 @@ def test_split_channel_bitwise_raises():
False,
[np.int8, np.int16, np.int32],
)
pytest.raises(ValueError, split_channel_bitwise, test_df, "a", ["b", "c"], 3, [np.int8])
pytest.raises(ValueError, split_channel_bitwise, test_df, "a", ["b", "c"], 3, False, [np.int8])
pytest.raises(
ValueError,
split_channel_bitwise,
Expand Down

0 comments on commit 208c5a6

Please sign in to comment.