Skip to content

Commit

Permalink
implement more appropriate fixes for typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Oct 15, 2023
1 parent 4f4ef93 commit cc058ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions sed/calibrator/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,10 +1732,8 @@ def peakdetect1d(
if lookahead < 1:
raise ValueError("Lookahead must be '1' or above in value")

if not (np.isscalar(delta) and cast(int, delta) >= 0):
if not (np.ndim(delta) == 0 and delta >= 0):
raise ValueError("delta must be a positive number")
# Hack because TypeGuard with numpy 1.22.4 seems broken
delta = cast(int, delta)

# maxima and minima candidates are temporarily stored in
# mx and mn respectively
Expand Down
6 changes: 2 additions & 4 deletions tests/test_binning.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""This file contains code that performs several tests for the sed.binning module
"""
from typing import Any
from typing import cast
from typing import List
from typing import Sequence
from typing import Tuple
Expand Down Expand Up @@ -394,9 +393,8 @@ def test_simplify_binning_arguments(
ranges_,
)

for i, bin_ in enumerate(bins__):
# TODO: Why does typing fail?
np.testing.assert_array_equal(cast(np.ndarray, bin_), bins_expected[i])
for i, _ in enumerate(bins__):
np.testing.assert_array_equal(bins__[i], bins_expected[i])
np.testing.assert_array_equal(axes__[i], axes_expected[i])
if ranges__ is not None:
np.testing.assert_array_equal(ranges__[i], ranges_expected[i])
Expand Down

0 comments on commit cc058ff

Please sign in to comment.