Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
steinnymir committed Oct 23, 2023
1 parent eaeeff4 commit acc9c4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
6 changes: 3 additions & 3 deletions sed/calibrator/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2237,9 +2237,9 @@ def apply_energy_offset(
signs = [signs]
if reductions is None:
reductions = [None] * len(columns)
columns_: Sequence[str] = []
reductions_: Sequence[str] = []
to_roll: Sequence[str] = []
columns_: List[str] = []
reductions_: List[str] = []
to_roll: List[str] = []

for c, r in zip(columns, reductions):
if r == "rolled":
Expand Down
32 changes: 13 additions & 19 deletions tests/loader/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,19 @@
)


@pytest.fixture
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],
},
)


def test_split_channel_bitwise(input_df):
def test_split_channel_bitwise():
"""Test split_channel_bitwise function"""
output_columns = ["output1", "output2"]
output_columns = ["b", "c"]
bit_mask = 2
expected_output = pd.DataFrame(
{
"input_column": [0, 1, 2, 3, 4, 5, 6, 7],
"output1": np.array([0, 1, 2, 3, 0, 1, 2, 3], dtype=np.int8),
"output2": np.array([0, 0, 0, 0, 1, 1, 1, 1], dtype=np.int32),
"a": [0, 1, 2, 3, 4, 5, 6, 7],
"b": np.array([0, 1, 2, 3, 0, 1, 2, 3], dtype=np.int8),
"c": np.array([0, 0, 0, 0, 1, 1, 1, 1], dtype=np.int32),
},
)
df = dd.from_pandas(input_df, npartitions=2)
result = split_channel_bitwise(df, "input_column", output_columns, bit_mask)
df = dd.from_pandas(test_df, npartitions=2)
result = split_channel_bitwise(df, "a", output_columns, bit_mask)
pd.testing.assert_frame_equal(result.compute(), expected_output)


Expand Down Expand Up @@ -82,7 +72,9 @@ 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, False, [np.int8])
pytest.raises(
ValueError, split_channel_bitwise, test_df, "a", ["b", "c"], 3, False, [np.int8]
)
pytest.raises(
ValueError,
split_channel_bitwise,
Expand All @@ -99,4 +91,6 @@ def test_split_channel_bitwise_raises():
"b": [0, 1, 2, 3, 4, 5, 6, 7],
},
)
pytest.raises(KeyError, split_channel_bitwise, other_df, "a", ["b", "c"], 3, False, None)
pytest.raises(
KeyError, split_channel_bitwise, other_df, "a", ["b", "c"], 3, False, None
)

0 comments on commit acc9c4a

Please sign in to comment.